Skip to content

Commit

Permalink
Make inherited relations and virtual attributes appear in model:show …
Browse files Browse the repository at this point in the history
…command (#48800)
  • Loading branch information
sebj54 authored Oct 24, 2023
1 parent 6350194 commit b52de33
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/Illuminate/Database/Console/ShowModelCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use Doctrine\DBAL\Schema\Index;
use Doctrine\DBAL\Types\DecimalType;
use Illuminate\Contracts\Container\BindingResolutionException;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\Relation;
use Illuminate\Support\Facades\Gate;
use Illuminate\Support\Str;
Expand Down Expand Up @@ -158,7 +159,7 @@ protected function getVirtualAttributes($model, $columns)
->reject(
fn (ReflectionMethod $method) => $method->isStatic()
|| $method->isAbstract()
|| $method->getDeclaringClass()->getName() !== get_class($model)
|| $method->getDeclaringClass()->getName() === Model::class
)
->mapWithKeys(function (ReflectionMethod $method) use ($model) {
if (preg_match('/^get(.+)Attribute$/', $method->getName(), $matches) === 1) {
Expand Down Expand Up @@ -198,7 +199,7 @@ protected function getRelations($model)
->reject(
fn (ReflectionMethod $method) => $method->isStatic()
|| $method->isAbstract()
|| $method->getDeclaringClass()->getName() !== get_class($model)
|| $method->getDeclaringClass()->getName() === Model::class
)
->filter(function (ReflectionMethod $method) {
$file = new SplFileObject($method->getFileName());
Expand Down

0 comments on commit b52de33

Please sign in to comment.