laravel-ide-helper icon indicating copy to clipboard operation
laravel-ide-helper copied to clipboard

Support for enum-casts

Open eschricker opened this issue 2 years ago • 3 comments

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',
  ];
...
}

eschricker avatar Jun 01 '22 06:06 eschricker

In my case, IDE Helper its correctly typing enum casts. image 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

Bosphoramus avatar Mar 12 '24 14:03 Bosphoramus

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?

Bosphoramus avatar Mar 12 '24 15:03 Bosphoramus