How to handle undefined variable when I have to include or extend that blade file in other files
2
There are 2 answers
0
On
You can pass the variable to the included view with
@include('view.name', ['user' => $user])
. You can also check the document about this on https://laravel.com/docs/8.x/blade#including-subviews
You can share your desired data in any blade file by sharing data with those blades.
In your AppServiceProvider
Now,
$user
is available in all of your blade files.