Laravel and Phpstorm: model methods not recognized in collections

When I do something like: $ solicitud = Solicitud :: find ($ id); $ extras = $ solicitud-> extras ();

PHPstorm does not recognize $ solicitud as a Solicitud model and shows a warning in the extras () method: "No additional methods found in Illuminate / Support / Collection | static"

If I use @var annotation the warning goes away, but is there a way to fix this automatically?

+3


source to share


1 answer


I had this problem earlier with Laravel 4 where the models were just expanding \Eloquent

, while this is programmatically fine, PHPStorm doesn't know what \Eloquent

is its only setting after laravel starts its load, register the aliases in your config files.

In your model, you just need to do the extension Illuminate\Database\Eloquent\Model

.



use Illuminate\Database\Eloquent\Model as Eloquent;

class Solicitud extends Eloquent {
    // Usual model code
}

      

0


source







All Articles