Everything on Eloquent.
3 articles tagged Eloquent — sorted newest first.
Replacing String Constants with PHP Backed Enums in Laravel Models
String constants like STATUS_PENDING are typo-prone, unautocompleted, and impossible to enumerate exhaustively. PHP backed enums fix all of that — and Laravel has native support throughout.
PHP Readonly Classes as Value Objects in Laravel
Primitive obsession is one of those code smells that's easy to ignore — until you're debugging which integer is pounds and which is pence. PHP readonly classes fix that cleanly.
PHP 8.4 Property Hooks in Laravel Models
PHP 8.4 property hooks are a tidy language-level alternative to getters and setters — but before you reach for them in your Eloquent models, there's a catch worth understanding.