I have the following tables setup in my application:
user
job_title
job_title_user
(pivot table)
I have setup a relationship model for job titles in the user
model, like so:
/**
* The job titles that belong to the user.
*
* @return Object
*/
public function jobTitles()
{
return $this->belongsToMany('App\Models\User\JobTitle');
}
I want to be able to select multiple rows from the user table, whilst joining on the job_title_id
field from the job_title_user
table.
So basically i'm looking to do a select on the user table, but also select which job titles the user has assigned to them.
How can I achieve this?
Thanks!
from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/1HdEgUP
via IFTTT
Aucun commentaire:
Enregistrer un commentaire