链街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.
 
 
 
 

70 lines
1.8 KiB

<?php
namespace App\Models\v3;
use Dcat\Admin\Traits\HasDateTimeFormatter;
use Illuminate\Database\Eloquent\SoftDeletes;
use Illuminate\Database\Eloquent\Model;
class SystemConfig extends Model
{
use HasDateTimeFormatter;
use SoftDeletes;
protected $table = 'lanzu_system_config';
protected $dateFormat = 'U';
/* 查询记录数 limit */
protected $perPage = 10;
public static $_CATEGORY= [1=>'奖励类',2=>'店铺设置类',3=>'市场管理后台配置',4=>'订单相关设置',5=>'提现设置'];
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] : '';
}
/**
* 根据id获取单条信息
* @param int $id
* @param string $field
* @return string
*/
public static function getInfo($id,$field = '*')
{
return self::select($field)->find($id);
}
/**
* 获取数组
* id为键
* @return array
*/
public static function getArray($where = [], $options = [])
{
$model = self::whereNull('deleted_at');
if(!empty($where)){
$model->where($where);
}
$list = $model->pluck('id','value')->toArray();
if(!empty($options)){
$new = array_merge($options,$list);
return array_flip($new);
}else{
return array_flip($list);
}
}
}