Code Vision: No Usage shown for Laravel Custom Attributes Follow
I'm using the latest version of PhpStorm (2022.3.1) with the new Code Vision and Laravel 9+.
Problem: No Usage shown for Laravel Custom Attributes
This is not a huge issue, but rather an eyesore.
When I use a Model to create a custom Attribute like this:
public function getFormattedStartDateAttribute(): string
{
if (!$this->start_date) {
return 'TBD';
} else {
return $this->start_date->format('M. d, Y');
}
}
And then use it in the View like this or this:
-
Date
{{ $event->formattedStartDate }}
-
Date
{{ $event->formatted_start_date }}
There is no usage record in the Model.
If I do this method:
public function isGuest(): bool
{
return $this->participant_parent_id !== null;
}
And then in the View:
{{ $participant->isGuest() }}
The usage is shown.
Is there a way to fix this so PhpStorm recognizes the Laravel Custom Attributes?
Please sign in to leave a comment.
@Vasiliy Yur
The same on StackOverflow: https://stackoverflow.com/q/75074655/783119
Hey,
Could you please check if "Find usages" (apart from Code Vision) works fine in this case?
"Find usages" works great. I click on it and it will tell me everywhere that method is being used.
I should note that when using Laravel you can call the custom attributes like this: