<?php
namespace App\Http\Middleware;

use Closure;
use Illuminate\Http\Request;

class CheckPermission
{
    public function handle(Request $request, Closure $next, string $permission)
    {
        if (!auth()->check() || !auth()->user()->canDo($permission)) {
            abort(403, 'Akses ditolak.');
        }
        return $next($request);
    }
}
