//追加字段 protected $appends = ['state']; //赋值 public function getStateAttribute() { $status = $this->attributes['status']; if ($status == 1) { return '已授权'; } elseif ($status == 2) { return '取消授权'; } else { return '未知'; } }
标签:laravel,status,return,字段,追加,赋值 From: https://www.cnblogs.com/kaka0318/p/16924406.html