I try to pass array to view for my relations.... I have users and projects table in realation....
Here is User Model:
public function projects(){
return $this ->belongsToMany('App\Project','project_user');
}
public function getUserList(){
return $this -> projects;
}
Here is my home controller:
public function project(User $project){
$this -> selected = $project;
return view('projects',array('selected' =>$project -> selected -> getUserList()->lists('id') ));
}
NOTE
If I change my home controller, this line:
return view('projects',array('selected' => $project -> selected -> getUserList()->lists('id') ));
into this:
return view('projects',array('selected' => Auth::user -> getUserList()->lists('id') ));
it works fine...
Anyone know why It now work with method injection?