I have a query using query builder.
my query:
$customer = DB::select(DB::raw('select *, CONCAT(lastname,", ",firstname, " ", if (middlename = null, "", middlename)) as fullname from customer
LEFT JOIN
(
select id,max(id) as maxCustomer from customer
) c on c.id = customer.id
where subscriber_id like "%'.$input.'%"
or lastname like "%'.$input.'%"
or firstname like "%'.$input.'%"
or middlename like "%'.$input.'%"
or CONCAT(lastname,", ",firstname, " ",middlename) like "%'.$input.'%"'));
I want to convert it to eloquent because I want to use laravel eager load. When I use $customer->load, it has an error, Call to a member function load() on a non-object. I am having difficulty to convert the left join part to eloquent.
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire