链街Dcat后台
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.
 
 
 
 

60 lines
1.5 KiB

<?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('name','id')->toArray();
if(!empty($options)){
return array_merge($options,$list);
}else{
return $list;
}
}
/**
* 根据id获取单条数据
*/
public static function getSettingInfo($id,$field = '*')
{
// return self::select($field)->find($id);
return self::select($field)->where('id',$id)->first();
}
}