Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

kshitizmittal's avatar

All roles can access method accept one

public function __construct()
    {
        $this->middleware('role:General Admin|ER Admin', ['only' => ['addAppraisal','performanceappraisal','assignflow','appraisalTemplateassignflowshow','storeFlow','statusappraisal','escalation','escalationShow','escalationStore','showAppraisalTemplate']]);
    }

I have 8 roles in my application and i want to give access to these methods to 7 of those roles. Is there any option to RESTRICT method for 1 role in constructor?

0 likes
3 replies
bugsysha's avatar
abort_if($role, Response::HTTP_FORBIDDEN, 'You shall not pass');
kshitizmittal's avatar

Is there a way I could use this in constructor like I did in an example above?

bugsysha's avatar

Never tried, but if that is not allowed in constructor then just create your own middleware and add that logic to it and you are good to go.

Please or to participate in this conversation.