hcker2000
hcker2000

Reputation: 615

VSCode auto compleate when using laravel?

More specifically when doing this from inside a model.

$this->myRelationship->

I would expect at this point in typing that I should get a list of all the eloquent collection methods but I do not.

I currently have the PHP Intelephense plugin installed. What am I missing here?

Upvotes: 0

Views: 1007

Answers (2)

Meow Kim
Meow Kim

Reputation: 484

I suggest laravel-ide-helper
It can creates phpDocs automatically like below.

php artisan ide-helper:models

So your intellisense(for me: PHP Intelephense) can recognize your model's properties. See it's Documentation for details

Upvotes: 0

Uroš Anđelić
Uroš Anđelić

Reputation: 1174

Intelephense sees the myRelationship() method but doesn't see it as a property because that property is resolved in the __get magic method. What you can do is document it above the model like:

/**
 * @property \Illuminate\Database\Eloquent\Collection $myRelationship
 */
class YourModel extends Model ...

and then you will have the autocomplete. Also this package can help you.

Upvotes: 1

Related Questions