You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
<?php
namespace App\Models\v3;
use Dcat\Admin\Traits\HasDateTimeFormatter;use Illuminate\Database\Eloquent\Model;
class CouponSetting extends Model{ use HasDateTimeFormatter; protected $table = 'lanzu_coupon_setting'; protected $dateFormat = 'U'; public static $_CATEGORY = [1=>'领取方式']; 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(); }}
|