diff --git a/plugins/ahmadfatoni/apigenerator/controllers/api/ProductsApiController.php b/plugins/ahmadfatoni/apigenerator/controllers/api/ProductsApiController.php index 0e2f820ef..d93b676c9 100644 --- a/plugins/ahmadfatoni/apigenerator/controllers/api/ProductsApiController.php +++ b/plugins/ahmadfatoni/apigenerator/controllers/api/ProductsApiController.php @@ -50,7 +50,8 @@ class ProductsAPIController extends Controller 'measure.translations:locale,model_id,attribute_data', 'currency.translations:locale,model_id,attribute_data' ]) - ->approvedAndFreshEndDate() + // ->approvedAndFreshEndDate() + ->approved() ->orderBy('ends_at', $sortOrder); if($categoryId) { // fetch offers by the category of the product @@ -64,7 +65,8 @@ class ProductsAPIController extends Controller 'measure.translations:locale,model_id,attribute_data', 'currency.translations:locale,model_id,attribute_data' ]) - ->approvedAndFreshEndDate() + // ->approvedAndFreshEndDate() + ->approved() ->orderBy('ends_at', $sortOrder); } else { $query = null; @@ -87,7 +89,8 @@ class ProductsAPIController extends Controller 'measure.translations:locale,model_id,attribute_data', 'currency.translations:locale,model_id,attribute_data' ]) - ->approvedAndFreshEndDate() + // ->approvedAndFreshEndDate() + ->approved() ->orderBy('ends_at', $sortOrder); } else { $query = null; @@ -133,7 +136,7 @@ class ProductsAPIController extends Controller 'vendor:id,name,surname,email,username' ])->find($id); - if ($data && $data->status == 'approved' && $data->ends_at >= \Carbon\Carbon::now()){ + if ($data && $data->status == 'approved' /*&& $data->ends_at >= \Carbon\Carbon::now()*/){ return response()->json($data, 200); } else { return $this->helpers->apiArrayResponseBuilder(404, 'not found', ['error' => 'Resource id=' . $id . ' could not be found']); diff --git a/plugins/tps/birzha/models/Product.php b/plugins/tps/birzha/models/Product.php index ec0780254..0cecdfba2 100644 --- a/plugins/tps/birzha/models/Product.php +++ b/plugins/tps/birzha/models/Product.php @@ -84,13 +84,19 @@ class Product extends Model return $query->where('status', 'approved')->where('ends_at','>=',\DB::raw('curdate()')); } + public function scopeApproved($query) { + return $query->where('status', 'approved'); + } + public function scopeSearched($query, $locale, $queryString) { if($locale == 'tm') { - $query = $query->approvedAndFreshEndDate() + // $query = $query->approvedAndFreshEndDate() + $query = $query->approved() ->where('name', 'like', "%${queryString}%"); } else { - $query = $query->approvedAndFreshEndDate() + // $query = $query->approvedAndFreshEndDate() + $query = $query->approved() ->whereHas('translations', function ($innerQuery) use ($locale, $queryString) { $innerQuery->where('locale', $locale)->where('attribute_data', 'like', "%${queryString}%"); });