From e71a488a93bfd8c27093b3ec2e4ee922f126c5ab Mon Sep 17 00:00:00 2001 From: A1Gard Date: Wed, 7 Feb 2024 04:06:40 +0330 Subject: [PATCH] fixing sqlite error for field function --- app/Http/Controllers/WebsiteController.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/app/Http/Controllers/WebsiteController.php b/app/Http/Controllers/WebsiteController.php index 034aaef..3d45fa1 100755 --- a/app/Http/Controllers/WebsiteController.php +++ b/app/Http/Controllers/WebsiteController.php @@ -75,9 +75,14 @@ class WebsiteController extends Controller 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);