Feature Description
This feature request is made of two parts. The first part might actually be a bug.
When we use a cast in the model like so:
class Person extends Model
{
protected function casts(): array
{
return [
'emails' => AsCollection::of(ContactEmail::class),
];
}
}
The genereated helper code is:
/**
* @property ContactEmail[]|Collection<array-key, App\Values\ContactEmail>|null $emails
Notice that the namespace for App\Values\ContactEmail is missing a prefix slash. So if I do:
I get this autocomplete:

but if I do $emails = $person->emails()->first->
I get no autocomplete. If I manually change generated helper code and add a prefix \ it works
Would it be possible to fix this? Also if I do emails' => AsCollection::of('\App\Values\ContactEmail'), (a class name as a string) it works correctly.
Additionally, if we use any other custom cast besides laravel's AsCollection or spatie's equivalent, there's no autocomplete whatsover. For example using this package
https://bagvalueobjects.com/laravel-eloquent-casting.html#casting-collections
if I have
class Person extends Model
{
protected function casts(): array
{
return [
'emails' => AsCollection::of(ContactEmail::class),
];
}
}
I get no autocomplete and generated helper code is just
* @property array|null $emails
Is there any way to make this autocomplete work?
Feature Description
This feature request is made of two parts. The first part might actually be a bug.
When we use a cast in the model like so:
The genereated helper code is:
Notice that the namespace for
App\Values\ContactEmailis missing a prefix slash. So if I do:I get this autocomplete:

but if I do
$emails = $person->emails()->first->I get no autocomplete. If I manually change generated helper code and add a prefix
\it worksWould it be possible to fix this? Also if I do
emails' => AsCollection::of('\App\Values\ContactEmail'),(a class name as a string) it works correctly.Additionally, if we use any other custom cast besides laravel's
AsCollectionor spatie's equivalent, there's no autocomplete whatsover. For example using this packageif I have
I get no autocomplete and generated helper code is just
Is there any way to make this autocomplete work?