I have a relationship in my app where a organisation can have many users and many users can have many organisations, in my model this looks like this,
Organisation.php
public function users() {
return $this->belongsToMany('User')->withPivot('is_admin');
}
User.php
public function organisations() {
$this->belongsToMany('Organisation');
}
What I am wanting to do, is run a query that has multiple where clauses and then return the row data and any pivot data.
For one where clause I would do the following,
$org = Organisation::find(1);
$orgUsers = $org->users();
What I cannot figure out is how I would user multiple wheres if I needed too?
return$this->belongsToMany('Organisation')and to$org->users()->get()or$org->users. Do you want to apply multiple where clauses to the organization, and then get its users? Or do you want its users, but applying other where clauses to it?