Support the ongoing development of Laravel.io →
Eloquent Views
Last updated 1 year ago.
0

What do you mean in one wiew ?

Last updated 1 year ago.
0

Let's say, i have a view called: backend.blade.php. And in that view i want to display all users and posts. Users have their own model, same with Posts. Can i share variables across views?

// UserController.php
View::make('backend')->with('users', $users)->with('posts', $posts);
Last updated 1 year ago.
0

Hi Heihachi, Maybe I'm misunderstanding your question, but can't you just do:

$users = User::all();
$posts = Post::all();

View::make('backend')->with('users', $users)->with('posts', $posts);

Maybe that is already what you are doing?

Last updated 1 year ago.
0

"Can i share variables across views?" -> Use View::share()

Doc : http://laravel.com/docs/responses

Last updated 1 year ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.