Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for enum-casts #1354

Open
eschricker opened this issue Jun 1, 2022 · 2 comments
Open

Support for enum-casts #1354

eschricker opened this issue Jun 1, 2022 · 2 comments

Comments

@eschricker
Copy link

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',
  ];
...
}
@Bosphoramus
Copy link

Bosphoramus commented Mar 12, 2024

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
Copy link

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants