Select custom columns from Laravel belongsToMany relation

后端 未结 3 1730
悲哀的现实
悲哀的现实 2021-01-13 05:06

Im trying to select only specific attributes on the many-to-many relation users, just like in one-to-one. But using select() on belongsToMany

3条回答
  •  生来不讨喜
    2021-01-13 05:28

    Computer::with(["users" => function($query){
    $query->select('column1','column2','...');
    }])->get();
    

提交回复
热议问题