Skip to content

Commit

Permalink
Bug ShowModelCommand not guessing policy (laravel#47043)
Browse files Browse the repository at this point in the history
* Fix: ShowModelCommand not guessing policy

* fix style

* Update src/Illuminate/Database/Console/ShowModelCommand.php

Co-authored-by: Jess Archer <[email protected]>

---------

Co-authored-by: Deniss Levskoi <[email protected]>
Co-authored-by: Taylor Otwell <[email protected]>
Co-authored-by: Jess Archer <[email protected]>
  • Loading branch information
4 people authored and milwad-dev committed May 12, 2023
1 parent 5ab56ed commit eab24ff
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions src/Illuminate/Database/Console/ShowModelCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

/**
Expand Down

0 comments on commit eab24ff

Please sign in to comment.