sort posts by ends_at field

This commit is contained in:
saparatayev 2022-05-23 16:49:26 +05:00
parent 2583fc4e06
commit b8de5337d5
3 changed files with 7 additions and 7 deletions

View File

@ -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;

View File

@ -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();

View File

@ -74,7 +74,7 @@ layout="birzha_empty"
<!-- Ru -->
<table class="mail" style="border: 1px solid #003197; border-radius: 5px; overflow: hidden; width: 100%; border-spacing: 0;">
<tr>
<tr style="background-image: url({{ asset('themes/birzha/assets/images/footer-bg.png') }})">
<th class="header" style="padding: 0; position: relative;">
<div class="header_row" style=" display: flex; align-items: center; padding: 10px 20px;">
<div class="logo" style="width: 44px; height: 44px; margin-right: 20px; position: relative; z-index: 2;">
@ -142,7 +142,7 @@ layout="birzha_empty"
<!-- Eng -->
<table class="mail" style="border: 1px solid #003197; border-radius: 5px; overflow: hidden; width: 100%; border-spacing: 0;">
<tr>
<tr style="background-image: url({{ asset('themes/birzha/assets/images/footer-bg.png') }})">
<th class="header" style="padding: 0; position: relative;">
<div class="header_row" style=" display: flex; align-items: center; padding: 10px 20px;">
<div class="logo" style="width: 44px; height: 44px; margin-right: 20px; position: relative; z-index: 2;">