//追加字段
protected $appends = ['state'];
//赋值
public function getStateAttribute()
{
$status = $this->attributes['status'];
if ($status == 1) {
return '已授权';
} elseif ($status == 2) {
return '取消授权';
} else {
return '未知';
}
}
laravel 模型追加字段并赋值
最新推荐文章于 2024-07-12 15:51:39 发布