Laravel 5 的关联模型如何设置只查询部分字段
我现在在学习laravel5,有个问题就是定义了关联模型之后,我想请问如何设置关联的模型的字段,我并不想获取全部的字段,只希望获取部分字段,并不像获取user的全部字段内容
public function user() { return $this->hasOne('App\Model\User','user_id'); }
关于 LearnKu
同问
$list = self::select(['id','images','title','effective','status'])
->with('Device:name')
关联模型的字段写在模型后面,以逗号分隔