How to set laravel custom primary key

Imagine you have an id in your table called product_id that you want to be as a primary key instead of id. In this scenario, you can set your custom primary key in your model.   View the code on Gist. Now you are able to use product_id as a primary key of the Product model.

Read more...

How to use laravel wherebetween together

Using Laravel whereBetween is tricky in some cases. Normally laravel wherebetween takes two arguments to check. Let’s check how to do that. Just simply use- $reservations = Reservation::whereBetween(‘reservation_from’, [$from, $to])->get(); Now imagine that you need to use more condition on that. $reservations = Reservation::whereBetween(‘reservation_from’, [$from_from, $to_from]) ->orWhereBetween(‘reservation_to’, [$from_to, $to_to]) ->get(); Hope it will work.

Read more...

How to set Crontab job in Macbook

I will show you the simplest way that how to set crontab job in Macbook. Let’s see here. How to use? Go to terminal, and write following line, then hit enter. env EDITOR=nano crontab -e Now you are able to write your cron instructions. Just add whatever you want. I am showing you one example- *…

Read more...

Laravel Carbon Display Local Dates and Time

If you use laravel and want to make it localized your date time, I think Laravel Carbon Display Local Dates and Time will help you to achieve. View the code on Gist. Now based on your requirement, you can assign any place name that you want. Ref: http://php.net/manual/en/timezones.asia.php    

Read more...