Quick Tips

Laravel model binding key

Route Model Binding: How to Change The Key

Laravel has a great feature of binding models by id field. So you can specify edit(User $user) and system would know to find the user from ID in the URL. But what if you want to bind by some other field?
wildcard subdomain Laravel

Wildcard Subdomain in Routes: Assign Subdomain for Every User

In modern multi-tenancy systems, it's pretty popular to give a specific sub-domain for every user or company, like laraveldaily.slack.com. How to handle these subdomains in Laravel routes?

Invokable Controllers with One Specific Action

Sometimes you need to create a controller which doesn't cover all seven resourceful methods, like index(), create(), store() etc. You just need controller which does one thing and you're struggling how to name that method. No more struggle, there's __invoke() method.
Laravel image validation rules

Four Laravel Validation Rules for Images and Photos

Laravel Validation mechanism has a lot of various rules. Let's pick the ones that can be applied to graphical files.

Laravel Group Query Result by Day/Month/Year

Quick tip for those who want to list some events, grouping them by some date value - by day, month, year etc.

How to add new .env variable, so teammates would notice?

A common problem while working in a team is some custom variables needed, when only one person on the team knows that they are needed, and then other people have errors because they don't have that variable. Like API Tokens for 3rd party apps, default values for some function - basically, anything that should be in .env file. So here's an instruction for you, how to put new environment variables correctly, without screwing up teammates work.

Validate Max File Size in Laravel, PHP and Web-Server

I got this question at least a dozen times: "I'm raising my file validation rule in Laravel to 20 MB but still get errors, it doesn't work". So decided to expand on it and explain the reason, and what to do.

How to Change Date Format in Laravel and jQuery UI DatePicker

One of the most often things to change in web-projects is adapting it to a certain geographical area - language and timezones are two examples. But also there's a date format, which can be pretty different in certain parts of the world. How to handle it properly in Laravel?

How to (Easily) Create a Custom Validation Rule

For some reason, only now I've found out about a feature that was introduced in Laravel 5.5 - artisan command that makes your validation rule, similar to Request classes. Let's see it in action.

How to Save User’s Last Login Time and IP Address

Quick tip of the day. Default Laravel Auth comes with User table and model, but without logging capability, so we need to build it ourselves. Fortunately, it's very easy, I will show you one method.

STAY CONNECTED

1,956FansLike
7,227FollowersFollow
8,174SubscribersSubscribe

NEWEST VIDEOS

RANDOM ARTICLES