I have the following models / tables setup in my application;
timesheet
- user_id
user
- id
supervisor_user
- user_id
- supervisor_id
Users get "assigned" to supervisors via the supervisor_user
pivot table.
I have the following relationship setup on the User
model, which gets supervisor users.
/**
* The supervisors that are assigned to the user.
*
* @return Object
*/
public function supervisors()
{
return $this->belongsToMany('App\Models\User\User', 'supervisor_user', 'user_id', 'supervisor_id')->withTimestamps();
}
I want to setup another relationship which gets a list of timesheets "assigned" to a supervisor. I'm guessing with hasManyThrough
relationship...but not exactly how to write the code for it.
How can I achieve what I need?
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire