jeudi 7 septembre 2017

Laravel 5.4 Sentinel User with eloquent relationship

How can you possibly get the many to many relationship of Sentinel users in laravel? The user will have projects and I need to get projects assigned to user after he/she login

//User
public function projects()
{
  return $this->belongsToMany('App\Project', 'project_user', 'u_id', 'pj_id');
}

//Project
public function users()
  {
    return $this->belongsToMany('App\User', 'project_user', 'pj_id', 'u_id');
  }


//Controller
     public function dashboard()
{
    $role = Sentinel::getUser();
    return view ('CMSLayout.holder.holderHome', compact('role');
}

I know it has something to do with like(see below).. but I don't know the right way to do it.

 Sentinel::getUser()->with('projects');

Thank you!.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire