Danaia
Danaia

Reputation: 71

Laravel 4 Multiple Bindings to A View

What is the best way to bind multiple results to a view? The following does not work but it captures my logic:

   public function show($id)
{
    $nests = Nest::with('user')->find($id);
    $notes = Note::with('nest')->where('nest_id', '=', $id);
    return View::make('nests.show', compact('nests', 'notes'));
}

Upvotes: 1

Views: 3338

Answers (2)

Jose Ortiz
Jose Ortiz

Reputation: 725

I used this code

return View::make('myviewfolder.myview', compact('view1','view2','viewN'));

I am using PHP 5.5

Here is the info on the compact function

PHP Compact Function

Upvotes: 0

Mark Smith
Mark Smith

Reputation: 621

I think this will do it:

return View::make('nests.show',array('nests'=>$nests,'notes'=>$notes));

Upvotes: 1

Related Questions