Merge pull request #1247 from openclassify/vedat

update
This commit is contained in:
Fatih Alp 2021-12-10 16:08:29 +03:00 committed by GitHub
commit e10a0a087a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -146,6 +146,10 @@ class AdvRepository extends EntryRepository implements AdvRepositoryInterface
$query = $query->whereDate('advs_advs.created_at', $param['created_at']); $query = $query->whereDate('advs_advs.created_at', $param['created_at']);
} }
if (!empty($param['start_publish_at']) && !empty($param['finish_publish_at'])) {
$query = $query->whereBetween('advs_advs.publish_at', [Carbon::make($param['start_publish_at'] . " 23:59"), Carbon::make($param['finish_publish_at'] . " 00:00")]);
}
foreach ($param as $para => $value) { foreach ($param as $para => $value) {
if (substr($para, 0, 3) === "cf_") { if (substr($para, 0, 3) === "cf_") {
$id = substr($para, 3); $id = substr($para, 3);
@ -304,7 +308,7 @@ class AdvRepository extends EntryRepository implements AdvRepositoryInterface
{ {
if (count($adv->files) != 0) { if (count($adv->files) != 0) {
$fileName = $adv->files[0]->name; $fileName = $adv->files[0]->name;
$ext = explode('.',$fileName); $ext = explode('.', $fileName);
if ($ext[1] != 'svg') { if ($ext[1] != 'svg') {
$fileName = 'tn-' . $fileName; $fileName = 'tn-' . $fileName;
} }
@ -316,10 +320,10 @@ class AdvRepository extends EntryRepository implements AdvRepositoryInterface
// Create thumbnail image // Create thumbnail image
$arrContextOptions=array( $arrContextOptions = array(
"ssl"=>array( "ssl" => array(
"verify_peer"=>false, "verify_peer" => false,
"verify_peer_name"=>false, "verify_peer_name" => false,
), ),
); );
@ -401,7 +405,8 @@ class AdvRepository extends EntryRepository implements AdvRepositoryInterface
return $this->model->orderBy('created_at', 'DESC')->whereIn('advs_advs.id', $ids)->get(); return $this->model->orderBy('created_at', 'DESC')->whereIn('advs_advs.id', $ids)->get();
} }
public function hideAdsWithoutOutOfStock($ads) { public function hideAdsWithoutOutOfStock($ads)
{
return $ads->filter( return $ads->filter(
function ($entry) { function ($entry) {
return (($entry->is_get_adv == true && $entry->stock > 0) || ($entry->is_get_adv == false)); return (($entry->is_get_adv == true && $entry->stock > 0) || ($entry->is_get_adv == false));
@ -584,14 +589,16 @@ class AdvRepository extends EntryRepository implements AdvRepositoryInterface
->get(); ->get();
} }
public function currentAds() { public function currentAds()
{
return $this->newQuery()->whereDate('finish_at', '>=', date("Y-m-d H:i:s")) return $this->newQuery()->whereDate('finish_at', '>=', date("Y-m-d H:i:s"))
->where('status', '=', 'approved') ->where('status', '=', 'approved')
->where('slug', '!=', '') ->where('slug', '!=', '')
->orderBy('publish_at', 'desc'); ->orderBy('publish_at', 'desc');
} }
public function expiredAds() { public function expiredAds()
{
return $this->newQuery() return $this->newQuery()
->whereDate('finish_at', '<', date("Y-m-d H:i:s")) ->whereDate('finish_at', '<', date("Y-m-d H:i:s"))
->where('slug', '!=', '') ->where('slug', '!=', '')