Source: darkghosthunter.medium.com

Laravel: PHPDocs for Models everyone should have

Category: Laravel, PHP

With that bunch of logic behind the scenes, it’s normal for an IDE to just not understand what’s going on.

When the IDE is not “intelligent enough” to understand what happens behind methods like __call() and __get(), we end up with no code assistance.

This declarations allows PHPStorm (my favorite) and other IDE to understand that magic, at least in an acceptable state.

Opening with query() will allow your IDE to also mix in your local scopes since we also set it to return the model.

If your model is using timestamps, it’s nice to also add them in the PHPDoc, specially if you work with them constantly.
Newsletter

Get the latest Laravel/PHP jobs, events and curated articles straight to your inbox, once a week

Glimpse streamlines Laravel development by seamlessly deploying GitHub pull requests to preview environments with the help of Laravel Forge. Glimpse streamlines Laravel development by seamlessly deploying GitHub pull requests to preview environments with the help of Laravel Forge.
Fathom Analytics | Fast, simple and privacy-focused website analytics. Fathom Analytics | Fast, simple and privacy-focused website analytics.
Shirts painstakingly handcrafted by under-caffeinated developers. Shirts painstakingly handcrafted by under-caffeinated developers.
Community Partners