From eab24ff92c1a28aff0200209694858bb3116cb11 Mon Sep 17 00:00:00 2001 From: dorkster100 Date: Fri, 12 May 2023 06:07:55 +0300 Subject: [PATCH] Bug ShowModelCommand not guessing policy (#47043) * Fix: ShowModelCommand not guessing policy * fix style * Update src/Illuminate/Database/Console/ShowModelCommand.php Co-authored-by: Jess Archer --------- Co-authored-by: Deniss Levskoi Co-authored-by: Taylor Otwell Co-authored-by: Jess Archer --- src/Illuminate/Database/Console/ShowModelCommand.php | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/Illuminate/Database/Console/ShowModelCommand.php b/src/Illuminate/Database/Console/ShowModelCommand.php index 4075a3cf3d9d..8e9b5ac2177d 100644 --- a/src/Illuminate/Database/Console/ShowModelCommand.php +++ b/src/Illuminate/Database/Console/ShowModelCommand.php @@ -106,10 +106,9 @@ public function handle() */ protected function getPolicy($model) { - return collect(Gate::policies()) - ->filter(fn ($policy, $modelClass) => $modelClass === get_class($model)) - ->values() - ->first(); + $policy = Gate::getPolicyFor($model::class); + + return $policy ? $policy::class : null; } /**