'领取方式']; public static $status = ['禁用','正常']; protected $appends = [ 'category_text', 'status_text' ]; public function getCategoryTextAttribute($value) { $value = $value ? $value : $this->category; return isset(self::$category[$value]) ? self::$category[$value] : ''; } public function getStatusTextAttribute($value) { $value = $value ? $value : $this->status; return isset(self::$status[$value]) ? self::$status[$value] : ''; } /** * 获取数组 */ public static function getSettingArray($where = [],$options = []) { $model = self::where('status',1) ->whereNull('deleted_at'); if(!empty($where)){ $model->where($where); } $list = $model->pluck('id','name')->toArray(); if(!empty($options)){ $new = array_merge($options,$list); return array_flip($new); }else{ return array_flip($list); } } /** * 根据id获取单条数据 */ public static function getSettingInfo($id,$field = '*') { // return self::select($field)->find($id); return self::select($field)->where('id',$id)->first(); } }