Skip to content
Advertisement

How to concatenate columns with Laravel 4 Eloquent?

I have a table called tenantdetails which contains

JavaScript

and I want to retrieve First_Name and Last Name as one column via the concatenation function of MySQL. So I write in my controller as follows

JavaScript

But results the following error:

JavaScript

How can we avoid the backticks while calling a function of MySQL in Laravel Eloquent. I am interested only in Eloquent (not in fluent query). Thanks in advance.

Update

Thanks to @Andreyco for helping me. We can achieve this in a more elegant way using Laravel models, as below:

In our model:

JavaScript

and in our controller:

JavaScript

Advertisement

Answer

JavaScript
User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement