Question:
i have two pages file in my view first is myhome blade
then second is category blade
and both of them using extends asidenav
my problem is when im redirecting to category file it gives me a error Undefined variable: categories
but in my home file when im redirecting it’s working fine . i will describe my code.in my controller
HomeController
i pass one data categories
to home.blade.php
home.blade.php
the output of my extends asidenav where the data i pass
categories
ahref
to redirect the category blade it gives the error undefined variable categories. but when im redirecting to home blade it’s working
the output of my category.blade.php
data categories
in my home blade and others file blade like a props
but i don’t have a idea how to do thatAnswer:
You could create a service provider responsible for inyecting those variables without declaring them in your controller, in your boot method :If you have better answer, please add a comment about this, thank you!