File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -608,6 +608,38 @@ public function middleware(string $middleware, callable $callback)
608608 });
609609 }
610610
611+ if ($ middleware === 'is ' ) {
612+ return app ()->registerMiddleware ('is ' , function ($ role ) use ($ callback ) {
613+ if ($ this ->user ()?->isNot($ role )) {
614+ $ callback ();
615+ }
616+ });
617+ }
618+
619+ if ($ middleware === 'isNot ' ) {
620+ return app ()->registerMiddleware ('isNot ' , function ($ role ) use ($ callback ) {
621+ if ($ this ->user ()?->is($ role )) {
622+ $ callback ();
623+ }
624+ });
625+ }
626+
627+ if ($ middleware === 'can ' ) {
628+ return app ()->registerMiddleware ('can ' , function ($ role ) use ($ callback ) {
629+ if ($ this ->user ()?->can($ role )) {
630+ $ callback ();
631+ }
632+ });
633+ }
634+
635+ if ($ middleware === 'cannot ' ) {
636+ return app ()->registerMiddleware ('cannot ' , function ($ role ) use ($ callback ) {
637+ if ($ this ->user ()?->cannot($ role )) {
638+ $ callback ();
639+ }
640+ });
641+ }
642+
611643 app ()->registerMiddleware ($ middleware , $ callback );
612644 }
613645
You can’t perform that action at this time.
0 commit comments