laravel-ide-helper
laravel-ide-helper copied to clipboard
Support for enum-casts
Summary
I have defined a enum which is used in the casts of a eloquent model. On the database the field is a smallint. The generated doc-block marks the element as int. It would be great if the enum could be referenced here.
/**
* App\Models\User.
...
* @property int $role
*/
class User extends Authenticatable {
...
protected $casts = [
'id' => 'integer',
'role' => UserRoles::class,
'enabled' => 'boolean',
];
...
}
In my case, IDE Helper its correctly typing enum casts.
If i hover over
role
it shows @var \App\Enums\Role $role
.
But i dont understand why the isAdmin()
function is not typed in IDE Helper files, it makes the IDE think that method is not defined on the enum, but it is.
Any idea why this could be? 👀 @barryvdh
Nevermind, it works perfectly fine, declared the isAdmin()
function as protected by mistake, making it public fixes it.
So this issue is already fixed, isnt it?