Author: Povilas Korop

AND-OR-AND + brackets with Eloquent

Eloquent is a great thing – you can build your query step-by-step and then call get() method. But sometimes it gets a little tricky for more complicated queries – for example, if you have multiple AND-OR conditions and you want to put brackets, how to do it properly?

Wednesday, June 24th, 2015

How to configure PHPStorm for PSR-2

Just a quick tip – since Laravel 5.1 now is coming with PSR-2 support (most important change is spaces indent instead of tabs), it makes sense to configure your editor to support that by default, if you haven’t done so already.

Tuesday, June 23rd, 2015

How to deal with possible empty Input variable?

Laravel is pretty strict about any kind of errors – if you try to use undefined variable or don’t pass a necessary parameter you immediately see Whoops or another kind of error, depending how you handle them. There’s a little trick with Input variables that might save you some time and lines of code.

Monday, June 22nd, 2015

Change date format with Accessors and Mutators

Pretty common situation – you have a date field in the MySQL database, which has a default format of YYYY-MM-DD, but the users need to see/edit dates in MM/DD/YYYY. How do you handle it properly in Laravel?

Monday, June 22nd, 2015

Laravel 5.1: Names for route groups

A small new feature in Laravel 5.1 – just for those who want to group their routes a little more properly. Now we can add a prefix not only to routes, but to the route groups as well.

Monday, June 22nd, 2015