TarikAli
2 months ago
477
5
Laravel

What is the Best Way to Share Menu Variable ?

Posted 2 months ago by TarikAli

Hello , Please i want to ask about menu in any website . I read 3 ways to do this.

1 - view::share in appServiceProvider Boot function ( or in middleware)

2 - view composer in appServiceProvider Boot function

3 - now in laravel 7 blade component

but also if i want the same menu to be in header and in footer. if i used view composer and passing the tow blades (header , footer) then the query will run Twice and also blade component ( laravel7 ) will run Twice . in this case my be view::share is the better . so what is the best way to share menu in all website components with out performance issue ? Thanks.

Please sign in or create an account to participate in this conversation.