diff --git a/app/Modules/SberPaymentOrder/Nova/Resources/Concerns/NovaSberPaymentOrderAuth.php b/app/Modules/SberPaymentOrder/Nova/Resources/Concerns/NovaSberPaymentOrderAuth.php index dbc6742..13bcdc0 100644 --- a/app/Modules/SberPaymentOrder/Nova/Resources/Concerns/NovaSberPaymentOrderAuth.php +++ b/app/Modules/SberPaymentOrder/Nova/Resources/Concerns/NovaSberPaymentOrderAuth.php @@ -8,6 +8,48 @@ use Illuminate\Http\Request; trait NovaSberPaymentOrderAuth { + /** + * Determine if the resource should be available for the given request. + * + * @param \Illuminate\Http\Request $request + * @return void + * + * @throws \Illuminate\Auth\Access\AuthorizationException + */ + public function authorizeToViewAny(Request $request) + { + $user = auth()->user(); + + if ($user->isMe()) { + return; + } + + /** @var SberPaymentOrder $resource */ + $resource = $this->resource; + if ($resource->user_id == auth()->id()) { + return; + } + + throw new AuthorizationException; + } + + /** + * Determine if the resource should be available for the given request. + * + * @param \Illuminate\Http\Request $request + * @return bool + */ + public static function authorizedToViewAny(Request $request) + { + $user = auth()->user(); + + if ($user->isMe()) { + return true; + } + + return false; + } + /** View */ public function authorizeToView(Request $request) {