i've created Middleware
php artisan make:middleware isTeacher
in App/Http/isTeacher.php i've placed the check:
namespace App\Http\Middleware;
use Closure;
use Illuminate\Support\Facades\Auth;
class isTeacher
{
public function handle($request, Closure $next)
{
$user = Auth::user();
if($user && $user->capability == 3)
{
return $next($request);
}
else
return redirect('/login');
}
}
than, i've defined the middleware in app/Http/Kernel.php
protected $routeMiddleware = [
...
'auth.teacher' => \App\Http\Middleware\isTeacher::class,
...
];
The question is: how I check the teacher capability in blade template? I'm trying with this:
@if (Auth::isTeacher())
but doesn't work
any help are appreciated
from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2FneaV3
via IFTTT
Aucun commentaire:
Enregistrer un commentaire