diff --git a/src/Console/ModelsCommand.php b/src/Console/ModelsCommand.php index 4ec323a62..51d3c1131 100644 --- a/src/Console/ModelsCommand.php +++ b/src/Console/ModelsCommand.php @@ -580,10 +580,7 @@ public function getPropertiesFromMethods($model) $isAttribute = is_a($type, '\Illuminate\Database\Eloquent\Casts\Attribute', true); $method = $reflection->getName(); if ( - Str::startsWith($method, 'get') && Str::endsWith( - $method, - 'Attribute' - ) && $method !== 'getAttribute' + Str::startsWith($method, 'get') && Str::endsWith($method, 'Attribute') && $method !== 'getAttribute' ) { //Magic getAttribute $name = Str::snake(substr($method, 3, -9)); @@ -599,15 +596,14 @@ public function getPropertiesFromMethods($model) $this->setProperty( Str::snake($method), $type, - $types->has('get'), - $types->has('set'), + $types->has('get') ?: null, + $types->has('set') ?: null, $this->getCommentFromDocBlock($reflection) ); } elseif ( - Str::startsWith($method, 'set') && Str::endsWith( - $method, - 'Attribute' - ) && $method !== 'setAttribute' + Str::startsWith($method, 'set') && + Str::endsWith($method, 'Attribute') && + $method !== 'setAttribute' ) { //Magic setAttribute $name = Str::snake(substr($method, 3, -9)); diff --git a/tests/Console/ModelsCommand/Attributes/Models/BackedAttribute.php b/tests/Console/ModelsCommand/Attributes/Models/BackedAttribute.php new file mode 100644 index 000000000..c6c8bf2b2 --- /dev/null +++ b/tests/Console/ModelsCommand/Attributes/Models/BackedAttribute.php @@ -0,0 +1,59 @@ +bigIncrements('id'); + $table->string('name'); + $table->string('name_read'); + $table->string('name_write'); + }); + } +}