show old approved posts too - api
This commit is contained in:
parent
108f9528d2
commit
1ee9712556
|
|
@ -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']);
|
||||
|
|
|
|||
|
|
@ -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}%");
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in New Issue