Skip to content

Commit b52de33

Browse files
authored
Make inherited relations and virtual attributes appear in model:show command (#48800)
1 parent 6350194 commit b52de33

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/Illuminate/Database/Console/ShowModelCommand.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
use Doctrine\DBAL\Schema\Index;
88
use Doctrine\DBAL\Types\DecimalType;
99
use Illuminate\Contracts\Container\BindingResolutionException;
10+
use Illuminate\Database\Eloquent\Model;
1011
use Illuminate\Database\Eloquent\Relations\Relation;
1112
use Illuminate\Support\Facades\Gate;
1213
use Illuminate\Support\Str;
@@ -158,7 +159,7 @@ protected function getVirtualAttributes($model, $columns)
158159
->reject(
159160
fn (ReflectionMethod $method) => $method->isStatic()
160161
|| $method->isAbstract()
161-
|| $method->getDeclaringClass()->getName() !== get_class($model)
162+
|| $method->getDeclaringClass()->getName() === Model::class
162163
)
163164
->mapWithKeys(function (ReflectionMethod $method) use ($model) {
164165
if (preg_match('/^get(.+)Attribute$/', $method->getName(), $matches) === 1) {
@@ -198,7 +199,7 @@ protected function getRelations($model)
198199
->reject(
199200
fn (ReflectionMethod $method) => $method->isStatic()
200201
|| $method->isAbstract()
201-
|| $method->getDeclaringClass()->getName() !== get_class($model)
202+
|| $method->getDeclaringClass()->getName() === Model::class
202203
)
203204
->filter(function (ReflectionMethod $method) {
204205
$file = new SplFileObject($method->getFileName());

0 commit comments

Comments
 (0)