Category: Laravel, Laravel, PHP, PHP, javascript, javascript

· October 5, 2020 · ⋆ Laravel In one of my articles, I’ve explained how you can extend class behavior using macros in Laravel. So for instance, if you want to add an additional method called makeKebab to Illuminate\Support\Collection class in Laravel, you can use a static macro method like so. A similar concept can be used to add custom validation rules to the Validator facade by using the extend method.

So, if we want to add a validation rule to check if each word in the attribute must begin with a capital letter, we can extend it like so.
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