Hi guys, Today I am going to discuss on a topic of laravel 5. Laravel is a very popular PHP framework.Day by day there are several new feature added by Laravel. So I am going to discuss on a very common and simple topic.I am introducing several new function of where conditions like whereDate(), whereMonth() etc .How will you use this function in your laravel application.Follow the step.
I give you one example table and understand how works this four query builder functions one by one.
This is a user table where all user is registered.
whereDate()
Here you can see the list of a user is registered.Now I want to fetch those record who registered on 2017-12-14.
$user=User::whereDate('registration_date','2017-12-14')->get()->toArray();
Here User is model class.
whereMonth()
Here you can see the list of a user is registered.Now I want to fetch those record who registered in December month.
$user=User::whereMonth('registration_date','12')->get()->toArray();
Here User is model class.
whereDay()
Here you can see the list of a user is registered.Now I want to fetch those record who registered on 07th of the month.
$user=User::whereDay('registration_date','07')->get()->toArray();
Here User is model class.
whereYear()
Here you can see the list of a user is registered.Now I want to fetch those record who registered on 2017.
$user=User::whereYear('registration_date','2017')->get()->toArray();
Here User is model class.
That’s all.You can use this in your application.If you face any problem comment on this post.