App\Providers\AppServiceProvider.php
boot()
method
Blade::directive('admin', function () {
$isAuth = 'false';
// check if the user authenticated is teacher
if (Auth::user() && Auth::user()->role== 2) {
$isAuth = 'true';
}
return "<?php if ($isAuth) { ?>";
});
Blade::directive('endadmin', function () {
return "<?php } ?>";
});
Step-3: Here Cache can be a problem: solve each time
php artisan cache:clear
php artisan config:clear
php artisan view:clear
Labels: Laravel, Web development