From b8de5337d5b02d0bf074c715837e22c36ad3fa0d Mon Sep 17 00:00:00 2001 From: saparatayev Date: Mon, 23 May 2022 16:49:26 +0500 Subject: [PATCH] sort posts by ends_at field --- .../controllers/api/ProductsApiController.php | 8 ++++---- plugins/tps/birzha/components/Offers.php | 2 +- plugins/tps/birzha/views/mail/product_reviewed.htm | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/plugins/ahmadfatoni/apigenerator/controllers/api/ProductsApiController.php b/plugins/ahmadfatoni/apigenerator/controllers/api/ProductsApiController.php index 342433a3a..62eaecd03 100644 --- a/plugins/ahmadfatoni/apigenerator/controllers/api/ProductsApiController.php +++ b/plugins/ahmadfatoni/apigenerator/controllers/api/ProductsApiController.php @@ -50,7 +50,7 @@ class ProductsAPIController extends Controller 'currency.translations:locale,model_id,attribute_data' ]) ->approvedAndFreshEndDate() - ->orderBy('updated_at', $sortOrder); + ->orderBy('ends_at', $sortOrder); if($categoryId) { // fetch offers by the category of the product $category = Category::find($categoryId); @@ -64,7 +64,7 @@ class ProductsAPIController extends Controller 'currency.translations:locale,model_id,attribute_data' ]) ->approvedAndFreshEndDate() - ->orderBy('updated_at', $sortOrder); + ->orderBy('ends_at', $sortOrder); } else { $query = null; } @@ -87,7 +87,7 @@ class ProductsAPIController extends Controller 'currency.translations:locale,model_id,attribute_data' ]) ->approvedAndFreshEndDate() - ->orderBy('updated_at', $sortOrder); + ->orderBy('ends_at', $sortOrder); } else { $query = null; } @@ -101,7 +101,7 @@ class ProductsAPIController extends Controller 'measure.translations:locale,model_id,attribute_data', 'currency.translations:locale,model_id,attribute_data' ]) - ->orderBy('updated_at', $sortOrder); + ->orderBy('ends_at', $sortOrder); } $data = $query ? $query->paginate($perPage) : null; diff --git a/plugins/tps/birzha/components/Offers.php b/plugins/tps/birzha/components/Offers.php index a6049c5d7..71f10aae1 100644 --- a/plugins/tps/birzha/components/Offers.php +++ b/plugins/tps/birzha/components/Offers.php @@ -86,7 +86,7 @@ class Offers extends ComponentBase $productSlug = $this->property('productSlug'); $offerId = $this->property('offerId'); - $query = Product::where('status', 'approved')->where('ends_at','>=',\Carbon\Carbon::now())->orderBy('updated_at', $sortOrder); + $query = Product::where('status', 'approved')->where('ends_at','>=',\Carbon\Carbon::now())->orderBy('ends_at', $sortOrder); if($cSlug != '') { //fetch offers by the category of the product $category = Category::transWhere('slug', $cSlug, Session::get('rainlab.translate.locale'))->first(); diff --git a/plugins/tps/birzha/views/mail/product_reviewed.htm b/plugins/tps/birzha/views/mail/product_reviewed.htm index c1b7aa0d2..8e98d2312 100644 --- a/plugins/tps/birzha/views/mail/product_reviewed.htm +++ b/plugins/tps/birzha/views/mail/product_reviewed.htm @@ -74,7 +74,7 @@ layout="birzha_empty" - +