Reputation: 915
I'm simply trying to return three variables as shown below. I'm receiving an undefined variable: udraft which is the third variable. If I make them only two variables, it will work. Is there some limitation here?
return view('tabs', ['post' => $posts] , ['acc' => $acc_usrs] , ['udraft' => $usr_draft]);
Upvotes: 0
Views: 46
Reputation:
you can use compact
return view('tabs', compact('posts','acc_usrs','usr_draft'));
Upvotes: 1
Reputation: 46
As stated in the Laravel Documentation, here, you should pass an array of data, not a single array for each variable.
Your code should be something like:
return view('tabs', ['post' => $posts, 'acc' => $acc_usrs, 'udraft' => $usr_draft]);
Or use the ->with()
method as mentioned in the documentation above.
Upvotes: 2
Reputation: 14288
Why not returning one array like this:
return view('tabs', [
'post' => $posts,
'acc' => $acc_usrs,
'udraft' => $usr_draft
]);
Upvotes: 1