ii iml0sto1
ii iml0sto1

Reputation: 1742

Laravel 8 Inertia passing data to AppLayout

I'm new to Laravel and I'm building an application with Laravel 8 and Inertia.

Usually I pass props to the Vue views through the PHP/Laravel controllers in the show method like so:

Inertia::render('Something', [
'namedProp' => 'data'
]);

That works so well, and god bless the almighty Laravel & Inertia team.

However I'm in the situation where I need to pass data to the AppLayout.vue file, I see that it already has the "user" prop, and I've searched and searched in the code but I just cant figure out where this data is passed from.

Basically I have a list of countries which is stored in a db table and accessible through a model, I need to pass this data to the AppLayout file like it would be when I pass it through Inertia::render

I hope im making the question clear, can anyone help me here :) ?

Upvotes: 1

Views: 6056

Answers (1)

Héctor William
Héctor William

Reputation: 796

I think what you want is to share data right?

this can help you Share Inertia Data.

However, if you´re planning to share date and make some logic there, I recommend you to create your own ShareInertiaData Middleware, is basically the same, but can help you keep your logics clean.

Upvotes: 1

Related Questions