Our blog

Did you know about view()->exists() function?

When you load a View from the Controller, there could be a situation when you don’t actually know which view to load – the name could be dynamic. For example, you would use different Blade templates for sending emails. There is a neat function to assure your chosen View file actually exists.

Friday, July 10th, 2015

Why use $appends with Accessors in Eloquent?

Eloquent has a convenient feature called Accessors – you can define your own custom fields on top of existing in the database table. But then there’s an Eloquent property $appends – should we use it or not? And what’s the difference?

Thursday, July 9th, 2015

CRUD: How to avoid building whole Form for Delete button

There is one annoying thing in Laravel RESTful approach – if you want to have Edit/Delete links in your tables, Edit is done easy with a link to URL, but for Delete you have to build the whole form. Is there a way to avoid it?

Wednesday, July 8th, 2015

There’s no PUT/PATCH/DELETE method, or how to build a Laravel form manually

Laravel RESTful controller mechanism is a very convenient thing – we generate Controller, write {{ Form::xxxx() }} methods in Blade templates and it works like magic. But there’s a little trick there which I want to talk about – it’s PUT/PATCH/DELETE methods for updating the database entries.

Tuesday, July 7th, 2015

belongsTo() and withTrashed() – linking to deleted row

Let’s say we have DB table products, which is linked to table categories with a field products.category_id = categories.id, Eloquent helps us to define a relation easily. But what if the category gets (soft) deleted, but we still need to have that relationship to be returned for history reasons? You can use withTrashed() method here.

Monday, July 6th, 2015

Did you know: affected rows after Eloquent update

Another quick tip – if you need to know, how many rows were actually affected if you launch Eloquent update() statement – it cannot be easier.

Friday, July 3rd, 2015

Laravel 5.1: empty option in Form::select with lists()

There is one small upgrade in Laravel 5.1 which breaks apps with earlier versions – it is related to <select> dropdown items. For a long time, Eloquent had a useful way of passing options to Form::select() – but adding an empty parameter doesn’t work in Laravel 5.1 anymore. Here’s what to do.

Thursday, July 2nd, 2015

Class ‘Form’ not found in Laravel 5?

One of the biggest confusions for people switching from Laravel 4 to Laravel 5 was using the Form class. Basically,

Wednesday, July 1st, 2015

How to customize “artisan down” page?

Artisan has a convenient command artisan down for an occasion when you need to put your web-project down for a while – for the case of deployment, maintenance or anything like that. Question – how to customize that temporary error page?

Tuesday, June 30th, 2015