Answer the question
In order to leave comments, you need to log in
How to make widgets in laravel?
Tell me how to make widgets like in laravel? For example, I want to make a menu widget, so that later in the view I can write something like: menu(top).. Something like this.. I know that there is a widgets package, but I wonder what solutions are in the framework itself. Now I got acquainted with the view composer, which partially solves my problem, but there is no direct interaction with it from the view. Those. As I understand it, it is impossible to transfer some parameters to it, only to receive data in a specific view. In general, I will be grateful for the answer)
Answer the question
In order to leave comments, you need to log in
As a primitive option, the logic for views can be moved to View Composers . In general, use arrilot/laravel-widgets and don't bother.
So you can also make a blade with menu markup, and connect it in another blade and pass parameters. Reuse your code for header, footer, cards, etc. This will not only reduce development time, but also facilitate further support of the project, since only one file will need to be changed, and the code will also look clearer.
A couple of lines and the list of users is ready! short, quick, clear, convenient. As for me)
@foreach($users as $user)
@include("view.user_card", ['user' => $user])
@endforeach
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question