Support the ongoing development of Laravel.io →
Authentication Security Requests
Last updated 1 year ago.
0

you can use middleware, since middleware supports parameter passing

class CheckPrivacy
{
    public function handle($request, Closure $next, $userId)
    {
        $user = User::find($userId);

        if (Auth->user()->hasBlocked($user)) {
             abort(403);
        }

        return $next($request);
    }

}

see this https://www.laravel.com/docs/5.3/middleware#middleware-parameters

on your controllers you can check like this

$this->middleware('checkPrivacy:'.$userId)
Last updated 7 years ago.
0

Great, thanks! Middleware is a good enough solution. I've used it in routes instead in controller.

0

Sign in to participate in this thread!

Eventy

Your banner here too?

BrakaTakl brakatakl Joined 16 Jul 2016

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.