Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Handle model instance in Authorize middleware.
This will help extending Middleware capabilities by giving it directly the Model to check. Implementation example : ```php <?php namespace App\Http\Middleware; use Closure; use Illuminate\Database\Eloquent\Model; use Illuminate\Auth\Middleware\Authorize; class AuthorizeCommand extends Authorize { /** * Handle an incoming request. * * @param \Illuminate\Http\Request $request * @param \Closure $next * @return mixed */ public function handle($request, Closure $next, $ability = null, ...$models) { if ((null !== $command = $request->route('command')) && $command instanceof Model ) { return parent::handle($request, $next, 'access', $command); } return $next($request); } } ```
- Loading branch information