U
U
User2021-08-24 11:07:58
Laravel
User, 2021-08-24 11:07:58

How to pass data to a Laravel Blade component through the View class?

Hello. There is a nav.blade.php component, it corresponds to the Nav instance of the View class. How to load data from db into nav.blade.php component via Nav directly? Those. do not load data into $slot on each page, but immediately use it with already loaded data. I hope I made the question clear. Thank you. <x-nav></x-nav>

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
inFureal, 2021-08-24
@Inkognida

Don't ever do that. The MVC pattern is very severely violated.
Is the book you opened downloading text from the writer's brain? No. If it's stupid, the model is for manipulating data, the view is for displaying them, the controller is in the form of an intermediary between the data and the view. (actually not a very good example)
If you want to add data from the database, drag it somewhere else. As a last resort, in a service provider with View::share(). But UNDER NO CIRCUMSTANCES should you access the database through views

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question