#3126 alibaba-theme improvment "e.3"

This commit is contained in:
Muammer Top 2021-01-20 18:05:42 +03:00
parent dbafd43a88
commit f30fb16705
3 changed files with 45 additions and 0 deletions

View File

@ -0,0 +1,25 @@
<?php
use Anomaly\Streams\Platform\Database\Migration\Migration;
class VisiosoftModuleAdvsAddIsBuyingFields extends Migration
{
protected $delete = false;
protected $stream = [
'slug' => 'advs',
];
protected $fields = [
'is_buying' => [
'type' => 'anomaly.field_type.boolean',
'config' => [
'default' => false,
]
],
];
protected $assignments = [
'is_buying'
];
}

View File

@ -67,6 +67,25 @@ class AdvCriteria extends EntryCriteria
return $ads;
}
public function buyingLeads($status = null){
$advModel = new AdvModel();
$latest_advs = AdvModel::query()
->whereDate('finish_at', '>=', date("Y-m-d H:i:s"))
->where('status', '=', 'approved')
->where('slug', '!=', '')
->where('is_buying', ($status == 'buying' ? true : false))
->orderBy('publish_at', 'desc')
->paginate($this->settings->value('streams::per_page'));
$ads = $advModel->getLocationNames($latest_advs);
foreach ($ads as $index => $ad) {
$ads[$index]->detail_url = $advModel->getAdvDetailLinkByModel($ad, 'list');
$ads[$index] = $advModel->AddAdsDefaultCoverImage($ad);
}
return $ads;
}
public function allAdvs()
{
$advModel = new AdvModel();

View File

@ -200,6 +200,7 @@ class AdvModel extends AdvsAdvsEntryModel implements AdvInterface
if ($country != null) {
$adv->setAttribute('country_name', $country->name);
$adv->setAttribute('country_abv', $country->abv);
}
if ($city != null) {
$adv->setAttribute('city_name', $city->name);