Answer the question
In order to leave comments, you need to log in
How to write such a SQL query in Laravel?
There is a query that works if you use it in phpmyadmin.
(SELECT * FROM products WHERE brand = 'Atlas Copco' ORDER BY created_At DESC) UNION (SELECT * FROM products WHERE brand != 'Atlas Copco' ORDER BY created_at DESC)
$products_atlas_copco = $category->products()->whereBrand('Atlas Copco')->orderBy('created_at', 'desc')->public();
$products = $category->products()->where('brand','!=','Atlas Copco')->orderBy('created_at', 'desc')->public()->union($products_atlas_copco);
$products_atlas_copco = $category->products()->whereBrand('Atlas Copco')->orderBy('created_at', 'desc')->public();
$products = $category->products()->where('brand','!=','Atlas Copco')->orderBy('created_at', 'desc')->public();
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question