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

Fathom Analytics | Fast, simple and privacy-focused website analytics. Fathom Analytics | Fast, simple and privacy-focused website analytics.
Achieve superior email deliverability with ToastMail! Our AI-driven tool warms up inboxes, monitors reputation, and ensures emails reach their intended destination. Sign up today for a spam-free future. Achieve superior email deliverability with ToastMail! Our AI-driven tool warms up inboxes, monitors reputation, and ensures emails reach their intended destination. Sign up today for a spam-free future.
Community Partners