我在任务模型中具有以下关系:
public function taskUser() {
return $this->belongsToMany('App\User', "task_user", 'task_id','user_receive_id')->using('App\TaskUser')
->withPivot('user_assigned_id');
}
当我在控制器中使用类似$task->taskUser->pivot
之类的东西时,我收到以下数据:
'data': [
task_id : 1,
user_receiver_id: 1,
user_assign_id: 2,
]
我想收到的是这样的东西:
'data' : [
task: {
all information from task model by id
}
user_assign_id: {
all information from task model by id
}
user_receiver_id: {
all information from task model by id
}
]