I use Laravels for many relationships. I have 2 projects and groups tables and a project_group pivot table
Now I can do something like this:
$groups = \App\Project::findOrFail(Auth::user() -> id)->groups()->where('adminid','=',Auth::user()->id)->get();
He will return only the groups ... Like this:
Design SEO
But I need to return like this:
Design(Project2,Project3) SEO(Porject1)
So, for each cycle, I need to assemble a group and the entire project associated with this group.
Here is my attitude towards the Project module:
public function groups(){ return $this ->belongsToMany('App\Group','project_group')->withPivot('admin_id'); }
source share