Category : Laravel

laravel eloquent order by varchar as int

Sometimes, You will need to order by a varchar column as an integer. for example if you have the billNumbers in two rows as 5 and 1400 the order as varchar in desc order will get that with 5 first then that with 1400. While the opposite is what is wanted in the ordering using integers.

calculate difference in days between two dates in laravel blade

this snippet will teach you how to calculate difference in days between two dates in laravel blade

laravel validation date must be after or equal another date

In this snippet I will provide code snippet for validate date in laravel to be after or equal another date

Laravel Validation one of two fields must be filled

In this snippet I will provide a way of validation one filed of two fields that must be filled

Laravel custom messages in lang folder

In this snippet I will teach you how to use custom messages in laravel lang folder to use in your controller or in your blade views

Login with Email or Phone or Username

In this snippet I will teach you how to make login process in laravel using email or phone number or username

Eloquent query with multiple withs or with with within a hirarchy

Some time, you may need to get a record with some relationship and at the same time you need to get an inner relationship to that relationship and so forth. Here is the key : $records->with(['bill', 'bill.sponsor', 'bill.sponsorSenator', 'bill.sponsor.actions']).

How to get collection by array of IDs

At this snippet I will teach you how to get laravel collection with your wanted records by using an array of IDs with default sorting and disabled sorting

Passing javascript array to laravel controller in URL

this snippet will teach you how to pass javascript array from javascript to laravel controller in the url and how to get that array back in laravel controller

Using datatables with examples

Here are different examples on how to use datatables library into your laravel project controllers.