mirror of
https://github.com/openclassify/openclassify.git
synced 2026-01-11 18:01:10 -06:00
Merge pull request #1197 from openclassify/dia
#1266 İlan Status değiştirme Fonksiyonları Merkezileştirilmeli
This commit is contained in:
commit
1bd898f82d
@ -2,7 +2,6 @@
|
||||
|
||||
use Anomaly\Streams\Platform\Image\Command\MakeImageInstance;
|
||||
use Anomaly\Streams\Platform\Message\MessageBag;
|
||||
use Anomaly\Streams\Platform\Model\Advs\AdvsCustomFieldsEntryModel;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
@ -38,8 +37,7 @@ class AdvModel extends AdvsAdvsEntryModel implements AdvInterface
|
||||
public function getDetailUrlAttribute()
|
||||
{
|
||||
// Checking for slug
|
||||
if($this->attributes)
|
||||
{
|
||||
if ($this->attributes) {
|
||||
return $this->getAdvDetailLinkByModel($this, 'list');
|
||||
}
|
||||
}
|
||||
@ -73,13 +71,11 @@ class AdvModel extends AdvsAdvsEntryModel implements AdvInterface
|
||||
public function getCategory1Attribute()
|
||||
{
|
||||
return $this->hasMany('Visiosoft\CatsModule\Category\CategoryModel', 'id', 'cat1')->first();
|
||||
|
||||
}
|
||||
|
||||
public function getCategory2Attribute()
|
||||
{
|
||||
return $this->hasMany('Visiosoft\CatsModule\Category\CategoryModel', 'id', 'cat1')->first();
|
||||
|
||||
}
|
||||
|
||||
public function getThumbnailAttribute()
|
||||
@ -112,6 +108,7 @@ class AdvModel extends AdvsAdvsEntryModel implements AdvInterface
|
||||
if ($addon = app('module.collection')->get($slug)) {
|
||||
return $addon->installed;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -120,8 +117,9 @@ class AdvModel extends AdvsAdvsEntryModel implements AdvInterface
|
||||
$isActive = DB::table('addons_extensions')->where('namespace', 'visiosoft.extension.' . $slug . '_provider')->first();
|
||||
if ($isActive == null) {
|
||||
return 0;
|
||||
} else
|
||||
return $isActive->enabled;
|
||||
}
|
||||
|
||||
return $isActive->enabled;
|
||||
}
|
||||
|
||||
public function is_active($id)
|
||||
@ -130,9 +128,11 @@ class AdvModel extends AdvsAdvsEntryModel implements AdvInterface
|
||||
->where('advs_advs.id', $id)
|
||||
->where('advs_advs.slug', '!=', "")
|
||||
->first();
|
||||
|
||||
if ($isActive->status != 'approved') {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -148,13 +148,14 @@ class AdvModel extends AdvsAdvsEntryModel implements AdvInterface
|
||||
if ($nullable_ad) {
|
||||
return $query->find($id);
|
||||
} else {
|
||||
return $query->where('advs_advs.slug', '!=', "")
|
||||
->find($id);
|
||||
return $query->where('advs_advs.slug', '!=', "")->find($id);
|
||||
}
|
||||
}
|
||||
|
||||
if ($nullable_ad) {
|
||||
return $query->newQuery();
|
||||
}
|
||||
|
||||
return $query->where('advs_advs.slug', '!=', "");
|
||||
}
|
||||
|
||||
@ -366,22 +367,6 @@ class AdvModel extends AdvsAdvsEntryModel implements AdvInterface
|
||||
return 0;
|
||||
}
|
||||
|
||||
public function saveCustomField($category_id, $field_id, $name)
|
||||
{
|
||||
$all = array();
|
||||
$all['category_id'] = $category_id;
|
||||
$all['field_id'] = $field_id;
|
||||
$all['name'] = $name;
|
||||
|
||||
if (AdvsCustomFieldsEntryModel::create($all)) {
|
||||
return response()->json([
|
||||
'success' => true
|
||||
]);
|
||||
} else {
|
||||
abort(404);
|
||||
}
|
||||
}
|
||||
|
||||
public function customfields()
|
||||
{
|
||||
if ($cFs = (array) json_decode($this->cf_json)) {
|
||||
@ -405,11 +390,6 @@ class AdvModel extends AdvsAdvsEntryModel implements AdvInterface
|
||||
return json_decode($this->cf_json, true);
|
||||
}
|
||||
|
||||
// public function getCustomFieldEditId($id) {
|
||||
// $custom_field = AdvsCustomFieldsEntryModel::query()->where('advs_custom_fields.id', $id)->first();
|
||||
// return DB::table('streams_assignments')->where('field_id', $custom_field->field_id)->first();
|
||||
// }
|
||||
|
||||
public function priceFormat($adv)
|
||||
{
|
||||
return number_format($adv->price, "2", ",", str_replace(' ', ' ', "."));
|
||||
|
||||
@ -0,0 +1,57 @@
|
||||
<?php namespace Visiosoft\AdvsModule\Adv\Command;
|
||||
|
||||
use Illuminate\Foundation\Bus\DispatchesJobs;
|
||||
use Visiosoft\AdvsModule\Adv\Event\ChangedStatusAd;
|
||||
use Visiosoft\PackagesModule\Package\PackageModel;
|
||||
|
||||
class UpdateClassifiedStatus
|
||||
{
|
||||
use DispatchesJobs;
|
||||
|
||||
protected $classified;
|
||||
protected $type;
|
||||
|
||||
public function __construct($classified, $type)
|
||||
{
|
||||
$this->classified = $classified;
|
||||
$this->type = $type;
|
||||
}
|
||||
|
||||
public function handle()
|
||||
{
|
||||
$defaultClassifiedPublishTime = setting_value('visiosoft.module.advs::default_published_time');
|
||||
if (is_module_installed('visiosoft.module.packages')) {
|
||||
$packageModel = new PackageModel();
|
||||
if ($packagePublishedTime = $packageModel->reduceTimeLimit($this->classified->cat1)) {
|
||||
$defaultClassifiedPublishTime = $packagePublishedTime;
|
||||
}
|
||||
}
|
||||
|
||||
switch ($this->type) {
|
||||
case 'approved':
|
||||
$update = [
|
||||
'status' => 'approved',
|
||||
];
|
||||
|
||||
if (!setting_value('visiosoft.module.advs::show_finish_and_publish_date')) {
|
||||
$update['publish_at'] = date('Y-m-d H:i:s');
|
||||
|
||||
if (is_null($this->classified->finish_at)) {
|
||||
$update['finish_at'] = date('Y-m-d H:i:s', strtotime(date('Y-m-d H:i:s') . ' + ' . $defaultClassifiedPublishTime . ' day'));
|
||||
}
|
||||
}
|
||||
|
||||
$this->classified->update($update);
|
||||
|
||||
break;
|
||||
default:
|
||||
$this->classified->update([
|
||||
'status' => $this->type,
|
||||
]);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
event(new ChangedStatusAd($this->classified));
|
||||
}
|
||||
}
|
||||
@ -56,8 +56,6 @@ interface AdvInterface extends EntryInterface
|
||||
|
||||
public function stockControl($id, $quantity);
|
||||
|
||||
public function saveCustomField($category_id, $field_id, $name);
|
||||
|
||||
public function customfields();
|
||||
|
||||
public function cFJSON();
|
||||
|
||||
@ -1,36 +1,16 @@
|
||||
<?php namespace Visiosoft\AdvsModule\Adv\Table\Handler;
|
||||
|
||||
use Anomaly\SettingsModule\Setting\Contract\SettingRepositoryInterface;
|
||||
use Anomaly\Streams\Platform\Ui\Table\Component\Action\ActionHandler;
|
||||
use Visiosoft\AdvsModule\Adv\Event\ChangedStatusAd;
|
||||
use Visiosoft\AdvsModule\Adv\Table\AdvTableBuilder;
|
||||
|
||||
use Visiosoft\AdvsModule\Adv\Command\UpdateClassifiedStatus;
|
||||
use Visiosoft\AdvsModule\Adv\Contract\AdvRepositoryInterface;
|
||||
|
||||
class Approve extends ActionHandler
|
||||
{
|
||||
public function handle(AdvTableBuilder $builder, array $selected, SettingRepositoryInterface $settingRepository)
|
||||
public function handle(AdvRepositoryInterface $advRepository, array $selected)
|
||||
{
|
||||
$model = $builder->getTableModel();
|
||||
|
||||
foreach ($selected as $id) {
|
||||
$defaultAdPublishTime = $settingRepository->value('visiosoft.module.advs::default_published_time');
|
||||
|
||||
if ($ad = $model->newQuery()->find($id)) {
|
||||
|
||||
$update = [
|
||||
'status' => 'approved',
|
||||
];
|
||||
|
||||
if (!setting_value('visiosoft.module.advs::show_finish_and_publish_date')) {
|
||||
$update = array_merge($update, [
|
||||
'finish_at' => date('Y-m-d H:i:s', strtotime(date('Y-m-d H:i:s') . ' + ' . $defaultAdPublishTime . ' day')),
|
||||
'publish_at' => date('Y-m-d H:i:s')
|
||||
]);
|
||||
}
|
||||
|
||||
$ad->update($update);
|
||||
|
||||
event(new ChangedStatusAd($ad));//Create Notify
|
||||
if ($classified = $advRepository->find($id)) {
|
||||
$this->dispatch(new UpdateClassifiedStatus($classified, 'approved'));
|
||||
}
|
||||
}
|
||||
|
||||
@ -38,4 +18,4 @@ class Approve extends ActionHandler
|
||||
$this->messages->success(trans('visiosoft.module.advs::field.approved'));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,28 +1,21 @@
|
||||
<?php namespace Visiosoft\AdvsModule\Adv\Table\Handler;
|
||||
|
||||
use Anomaly\Streams\Platform\Ui\Table\Component\Action\ActionHandler;
|
||||
use Visiosoft\AdvsModule\Adv\Event\ChangedStatusAd;
|
||||
use Visiosoft\AdvsModule\Adv\Table\AdvTableBuilder;
|
||||
|
||||
use Visiosoft\AdvsModule\Adv\Command\UpdateClassifiedStatus;
|
||||
use Visiosoft\AdvsModule\Adv\Contract\AdvRepositoryInterface;
|
||||
|
||||
class Decline extends ActionHandler
|
||||
{
|
||||
public function handle(AdvTableBuilder $builder, array $selected)
|
||||
public function handle(AdvRepositoryInterface $advRepository, array $selected)
|
||||
{
|
||||
$model = $builder->getTableModel();
|
||||
|
||||
foreach ($selected as $id) {
|
||||
$classified = $advRepository->find($id);
|
||||
|
||||
$ad = $model->find($id);
|
||||
$ad->status = 'declined';
|
||||
$ad->update();
|
||||
|
||||
event(new ChangedStatusAd($ad));//Create Notify
|
||||
|
||||
$this->dispatch(new UpdateClassifiedStatus($classified, 'declined'));
|
||||
}
|
||||
|
||||
if ($selected) {
|
||||
$this->messages->success(trans('visiosoft.module.advs::field.declined'));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,13 +1,9 @@
|
||||
<?php namespace Visiosoft\AdvsModule\Adv\Table\Handler;
|
||||
|
||||
use Anomaly\SettingsModule\Setting\Contract\SettingRepositoryInterface;
|
||||
use Anomaly\Streams\Platform\Model\EloquentModel;
|
||||
use Anomaly\Streams\Platform\Ui\Table\Component\Action\ActionHandler;
|
||||
use Anomaly\Streams\Platform\Ui\Table\TableBuilder;
|
||||
use Visiosoft\AdvsModule\Adv\Event\ChangedStatusAd;
|
||||
use Visiosoft\AdvsModule\Adv\Event\DeletedAd;
|
||||
use Visiosoft\AdvsModule\Adv\Table\AdvTableBuilder;
|
||||
|
||||
|
||||
class Delete extends ActionHandler
|
||||
{
|
||||
@ -49,4 +45,4 @@ class Delete extends ActionHandler
|
||||
$this->messages->warning(trans('streams::message.delete_success', compact('count')));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -3,7 +3,6 @@
|
||||
use Anomaly\Streams\Platform\Ui\Table\Component\Action\ActionHandler;
|
||||
use Visiosoft\AdvsModule\Adv\Table\AdvTableBuilder;
|
||||
|
||||
|
||||
class Extend extends ActionHandler
|
||||
{
|
||||
public function handle(AdvTableBuilder $builder, array $selected)
|
||||
@ -20,4 +19,4 @@ class Extend extends ActionHandler
|
||||
$this->messages->success(trans('visiosoft.module.advs::field.extended'));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,6 +1,5 @@
|
||||
<?php namespace Visiosoft\AdvsModule;
|
||||
|
||||
|
||||
use Anomaly\FilesModule\File\FileModel;
|
||||
use Anomaly\Streams\Platform\Addon\AddonCollection;
|
||||
use Anomaly\Streams\Platform\Addon\AddonServiceProvider;
|
||||
|
||||
@ -1,15 +1,14 @@
|
||||
<?php namespace Visiosoft\AdvsModule\Http\Controller\Admin;
|
||||
|
||||
use Anomaly\SettingsModule\Setting\Contract\SettingRepositoryInterface;
|
||||
use Anomaly\Streams\Platform\Application\Application;
|
||||
use Anomaly\Streams\Platform\Model\Advs\AdvsAdvsEntryTranslationsModel;
|
||||
use Anomaly\Streams\Platform\Ui\Form\FormBuilder;
|
||||
use Anomaly\UsersModule\User\Contract\UserRepositoryInterface;
|
||||
use Illuminate\Filesystem\Filesystem;
|
||||
use Illuminate\Http\Request;
|
||||
use Visiosoft\AdvsModule\Adv\Command\UpdateClassifiedStatus;
|
||||
use Visiosoft\AdvsModule\Adv\Contract\AdvRepositoryInterface;
|
||||
use Visiosoft\AdvsModule\Adv\AdvModel;
|
||||
use Visiosoft\AdvsModule\Adv\Event\ChangedStatusAd;
|
||||
use Visiosoft\AdvsModule\Adv\Form\SimpleAdvFormBuilder;
|
||||
use Visiosoft\AdvsModule\Adv\Table\AdvTableBuilder;
|
||||
use Anomaly\Streams\Platform\Http\Controller\AdminController;
|
||||
@ -68,23 +67,19 @@ class AdvsController extends AdminController
|
||||
}
|
||||
}
|
||||
|
||||
public function actions($id, $type, SettingRepositoryInterface $settings, AdvModel $advModel)
|
||||
public function actions($id, $type, AdvModel $advModel)
|
||||
{
|
||||
$ad = $advModel->where('advs_advs.id', '=', $id)->first();
|
||||
$ad->status = $type;
|
||||
$ad = $this->advRepository->find($id);
|
||||
|
||||
$default_adv_publish = $settings->value('visiosoft.module.advs::default_published_time');
|
||||
$ad->finish_at = date('Y-m-d H:i:s', strtotime(date('Y-m-d H:i:s') . ' + ' . $default_adv_publish . ' day'));
|
||||
$ad->publish_at = date('Y-m-d H:i:s');
|
||||
$this->dispatch(new UpdateClassifiedStatus($ad, $type));
|
||||
|
||||
//algolia Search Module
|
||||
// Algolia Search Module
|
||||
$isActiveAlgolia = $advModel->is_enabled('algolia');
|
||||
if ($isActiveAlgolia) {
|
||||
$algolia = new SearchModel();
|
||||
$algolia->updateStatus($id, $type, $settings);
|
||||
$algolia->updateStatus($id, $type);
|
||||
}
|
||||
$ad->update();
|
||||
event(new ChangedStatusAd($ad));//Create Notify
|
||||
|
||||
return back();
|
||||
}
|
||||
|
||||
|
||||
@ -11,8 +11,8 @@ use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\Cookie;
|
||||
use Visiosoft\AdvsModule\Adv\AdvModel;
|
||||
use Visiosoft\AdvsModule\Adv\Command\IsOptionsByCategory;
|
||||
use Visiosoft\AdvsModule\Adv\Command\UpdateClassifiedStatus;
|
||||
use Visiosoft\AdvsModule\Adv\Contract\AdvRepositoryInterface;
|
||||
use Visiosoft\AdvsModule\Adv\Event\ChangedStatusAd;
|
||||
use Visiosoft\AdvsModule\Adv\Event\CreatedAd;
|
||||
use Visiosoft\AdvsModule\Adv\Event\EditedAd;
|
||||
use Visiosoft\AdvsModule\Adv\Event\EditedAdCategory;
|
||||
@ -29,7 +29,6 @@ use Visiosoft\LocationModule\Country\Contract\CountryRepositoryInterface;
|
||||
use Visiosoft\LocationModule\District\DistrictModel;
|
||||
use Visiosoft\LocationModule\Neighborhood\NeighborhoodModel;
|
||||
use Visiosoft\LocationModule\Village\VillageModel;
|
||||
use Visiosoft\PackagesModule\Package\PackageModel;
|
||||
use Visiosoft\ProfileModule\Adress\Contract\AdressRepositoryInterface;
|
||||
use Visiosoft\SeoModule\Legend\Command\AddMetaData;
|
||||
|
||||
@ -1019,36 +1018,20 @@ class AdvsController extends PublicController
|
||||
);
|
||||
}
|
||||
|
||||
public function statusAds($id, $type, SettingRepositoryInterface $settings, Dispatcher $events)
|
||||
public function statusAds($id, $type)
|
||||
{
|
||||
$ad = $this->adv_model->getAdv($id);
|
||||
$auto_approved = $settings->value('visiosoft.module.advs::auto_approve');
|
||||
$default_published_time = $settings->value('visiosoft.module.advs::default_published_time');
|
||||
$autoApprove = setting_value('visiosoft.module.advs::auto_approve');
|
||||
|
||||
if ($auto_approved == true and $type == 'pending_admin') {
|
||||
if ($autoApprove && $type == 'pending_admin') {
|
||||
$type = "approved";
|
||||
}
|
||||
if ($type == "approved" and $auto_approved != true) {
|
||||
|
||||
if ($type == "approved" && !$autoApprove) {
|
||||
$type = "pending_admin";
|
||||
}
|
||||
|
||||
if ($type == "approved") {
|
||||
$this->adv_model->publish_at_Ads($id);
|
||||
if ($ad->finish_at == NULL and $type == "approved") {
|
||||
if ($this->adv_model->is_enabled('packages')) {
|
||||
$packageModel = new PackageModel();
|
||||
$published_time = $packageModel->reduceTimeLimit($ad->cat1);
|
||||
if ($published_time != null) {
|
||||
$default_published_time = $published_time;
|
||||
}
|
||||
}
|
||||
$this->adv_model->finish_at_Ads($id, $default_published_time);
|
||||
}
|
||||
}
|
||||
|
||||
$this->adv_model->statusAds($id, $type);
|
||||
|
||||
event(new ChangedStatusAd($ad));//Create Notify
|
||||
$this->dispatch(new UpdateClassifiedStatus($ad, $type));
|
||||
|
||||
if ($type === 'approved') {
|
||||
$message = trans('visiosoft.module.advs::message.approve_status_change');
|
||||
@ -1057,7 +1040,9 @@ class AdvsController extends PublicController
|
||||
} else {
|
||||
$message = trans('visiosoft.module.advs::message.passive_status_change');
|
||||
}
|
||||
|
||||
$this->messages->success($message);
|
||||
|
||||
return back();
|
||||
}
|
||||
|
||||
|
||||
@ -7,7 +7,6 @@ use Anomaly\UsersModule\User\Contract\UserRepositoryInterface;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Visiosoft\AdvsModule\Adv\AdvModel;
|
||||
use Visiosoft\AdvsModule\Adv\Event\ChangeStatusAd;
|
||||
use Visiosoft\AdvsModule\Status\Contract\StatusRepositoryInterface;
|
||||
use Visiosoft\LocationModule\Country\CountryModel;
|
||||
use Visiosoft\AlgoliaModule\Search\SearchModel;
|
||||
@ -98,11 +97,11 @@ class MyProfileController extends PublicController
|
||||
}
|
||||
}
|
||||
|
||||
public function statusAds($id, $type, SettingRepositoryInterface $settings, Dispatcher $events, AdvModel $advModel)
|
||||
public function statusAds($id, $type, AdvModel $advModel)
|
||||
{
|
||||
$ad = $advModel->getAdv($id);
|
||||
$auto_approved = $settings->value('visiosoft.module.advs::auto_approve');
|
||||
$default_published_time = $settings->value('visiosoft.module.advs::default_published_time');
|
||||
$auto_approved = setting_value('visiosoft.module.advs::auto_approve');
|
||||
$default_published_time = setting_value('visiosoft.module.advs::default_published_time');
|
||||
|
||||
if ($auto_approved == true AND $type == 'pending_admin') {
|
||||
$type = "approved";
|
||||
@ -125,13 +124,12 @@ class MyProfileController extends PublicController
|
||||
$isActiveAlgolia = $isActiveAlgolia->is_enabled('algolia');
|
||||
if ($isActiveAlgolia) {
|
||||
$algolia = new SearchModel();
|
||||
$algolia->updateStatus($id, $type, $settings);
|
||||
$algolia->updateStatus($id, $type);
|
||||
}
|
||||
|
||||
$status = $advModel->statusAds($id, $type);
|
||||
$events->dispatch(new ChangeStatusAd($id, $settings));//Create Notify
|
||||
|
||||
return response()->json(['status' => $status]);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user