Skip to content

Commit

Permalink
fixing sqlite error for field function
Browse files Browse the repository at this point in the history
  • Loading branch information
A1Gard committed Feb 7, 2024
1 parent 75f9ac9 commit e71a488
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion app/Http/Controllers/WebsiteController.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,14 @@ public function index()
public function cat(Cat $cat, Request $request)
{

$connection = config('database.default');
$driver = config("database.connections.{$connection}.driver");

$q = $cat->products()->where('active', 1)
->orderByRaw("FIELD(stock_status, \"IN_STOCK\", \"BACK_ORDER\", \"OUT_STOCK\")")
->orderByDesc($this->sort)->orderByDesc('id');
if ($driver == 'mysql'){
$q->orderByRaw("FIELD(stock_status, \"IN_STOCK\", \"BACK_ORDER\", \"OUT_STOCK\")");
}
if ($request->has('ext')) {
$q = $q->where('stock_status', 'IN_STOCK')
->where('stock_quantity', '>', 0);
Expand Down

0 comments on commit e71a488

Please sign in to comment.