• python
  • javascript
  • reactjs
  • sql
  • c#
  • java
Facebook Twitter Instagram
Devs Fixed
  • python
  • javascript
  • reactjs
  • sql
  • c#
  • java
Devs Fixed
Home ยป Resolved: how to pass one data view and others view page in laravel

Resolved: how to pass one data view and others view page in laravel

0
By Isaac Tonny on 17/06/2022 Issue
Share
Facebook Twitter LinkedIn

Question:

i have two pages file in my view first is my home 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
the output of my home.blade.php
you can see in my home blade there is a extends asidenav . inside of my asidenav extends the data categories i passed is inside of that asidenav to make a list of categories
the output of my extends asidenav where the data i pass categories
when i click the 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
but when i tried this code in my category controller it’s working fine the error of undefined variable categories not showing
my point here is i want to pass only single data categories in my home blade and others file blade like a props but i don’t have a idea how to do that

Answer:

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!

laravel laravel-5 laravel-7 laravel-8
Share. Facebook Twitter LinkedIn

Related Posts

Resolved: EntityFramework creates/runs migrations using parameterless DataContext instance

24/03/2023

Resolved: Visual Studio 2022 crashes when using breakpoints

24/03/2023

Resolved: How to get Union type from an array of objects in Flow?

24/03/2023

Leave A Reply

© 2023 DEVSFIX.COM

Type above and press Enter to search. Press Esc to cancel.