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

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