mirror of
https://github.com/openclassify/openclassify.git
synced 2026-01-11 18:01:10 -06:00
Merge pull request #635 from openclassify/dia
#1916 admin ad search not working
This commit is contained in:
commit
aec84e0f6c
@ -23,4 +23,6 @@ return [
|
||||
'choose_user' => 'Choose a user',
|
||||
'owner_updated_successfully' => 'The Owner Has Been Updated Successfully!',
|
||||
'no_add_found' => 'No Ad Found!',
|
||||
'replicated_success' => 'The ad has been replicated successfully!',
|
||||
'ad_doesnt_exist' => "This ad doesn't exist!",
|
||||
];
|
||||
|
||||
@ -4,6 +4,7 @@ use Anomaly\Streams\Platform\Model\Users\UsersUsersEntryModel;
|
||||
use Anomaly\Streams\Platform\Ui\Table\TableBuilder;
|
||||
use Anomaly\UsersModule\UsersModule;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Visiosoft\AdvsModule\Adv\Table\Filter\NameDescFilterQuery;
|
||||
use Visiosoft\AdvsModule\Adv\Table\Filter\UserFilterQuery;
|
||||
use Visiosoft\AdvsModule\Adv\Table\Handler\AdvHandler;
|
||||
use Visiosoft\AdvsModule\Adv\Table\Views\All;
|
||||
@ -40,10 +41,9 @@ class AdvTableBuilder extends TableBuilder
|
||||
*/
|
||||
protected $filters = [
|
||||
'search' => [
|
||||
'fields' => [
|
||||
'name',
|
||||
'advs_desc',
|
||||
]
|
||||
'filter' => 'input',
|
||||
'placeholder' => 'visiosoft.module.advs::field.search',
|
||||
'query' => NameDescFilterQuery::class,
|
||||
],
|
||||
'country',
|
||||
'id' => [
|
||||
|
||||
@ -0,0 +1,20 @@
|
||||
<?php namespace Visiosoft\AdvsModule\Adv\Table\Filter;
|
||||
|
||||
use Anomaly\Streams\Platform\Ui\Table\Component\Filter\Contract\FilterInterface;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
|
||||
class NameDescFilterQuery
|
||||
{
|
||||
|
||||
public function handle(Builder $query, FilterInterface $filter)
|
||||
{
|
||||
$appLocale = config('app.locale');
|
||||
$defaultLocale = setting_value('streams::default_locale');
|
||||
|
||||
$query->join('advs_advs_translations', 'advs_advs.id', '=', 'advs_advs_translations.entry_id');
|
||||
|
||||
$query->where('name', 'LIKE', '%' . $filter->getValue() . '%');
|
||||
$query->orWhere('advs_desc', 'LIKE', '%' . $filter->getValue() . '%');
|
||||
$query->orderByRaw("FIELD(locale, '$defaultLocale', '$appLocale') DESC");
|
||||
}
|
||||
}
|
||||
@ -4,13 +4,14 @@
|
||||
use Anomaly\SettingsModule\Setting\Contract\SettingRepositoryInterface;
|
||||
use Anomaly\Streams\Platform\Application\Application;
|
||||
use Anomaly\Streams\Platform\Entry\Contract\EntryInterface;
|
||||
use Anomaly\Streams\Platform\Model\Advs\AdvsAdvsEntryModel;
|
||||
use Anomaly\Streams\Platform\Model\Advs\AdvsAdvsEntryTranslationsModel;
|
||||
use Anomaly\Streams\Platform\Model\Cats\CatsCategoryEntryModel;
|
||||
use Anomaly\UsersModule\User\Contract\UserRepositoryInterface;
|
||||
use Anomaly\UsersModule\User\UserModel;
|
||||
use Illuminate\Filesystem\Filesystem;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Visiosoft\AdvsModule\Adv\Contract\AdvRepositoryInterface;
|
||||
use Visiosoft\AdvsModule\Adv\Table\Filter\CategoryFilterQuery;
|
||||
use Visiosoft\AdvsModule\Adv\Table\Filter\CityFilterQuery;
|
||||
use Visiosoft\AdvsModule\Adv\Table\Filter\StatusFilterQuery;
|
||||
@ -20,20 +21,30 @@ use Visiosoft\AdvsModule\Adv\Event\ChangedStatusAd;
|
||||
use Visiosoft\AdvsModule\Adv\Form\AdvFormBuilder;
|
||||
use Visiosoft\AdvsModule\Adv\Table\AdvTableBuilder;
|
||||
use Anomaly\Streams\Platform\Http\Controller\AdminController;
|
||||
use Visiosoft\AdvsModule\Option\Contract\OptionRepositoryInterface;
|
||||
use Visiosoft\CatsModule\Category\CategoryModel;
|
||||
use Visiosoft\LocationModule\City\CityModel;
|
||||
use Visiosoft\AlgoliaModule\Search\SearchModel;
|
||||
use Illuminate\Contracts\Events\Dispatcher;
|
||||
|
||||
|
||||
class AdvsController extends AdminController
|
||||
{
|
||||
private $model;
|
||||
private $advRepository;
|
||||
private $advsEntryTranslationsModel;
|
||||
private $optionRepository;
|
||||
|
||||
public function __construct(AdvModel $model)
|
||||
public function __construct(
|
||||
AdvModel $model,
|
||||
AdvRepositoryInterface $advRepository,
|
||||
AdvsAdvsEntryTranslationsModel $advsEntryTranslationsModel,
|
||||
OptionRepositoryInterface $optionRepository
|
||||
)
|
||||
{
|
||||
$this->model = $model;
|
||||
parent::__construct();
|
||||
$this->model = $model;
|
||||
$this->advRepository = $advRepository;
|
||||
$this->advsEntryTranslationsModel = $advsEntryTranslationsModel;
|
||||
$this->optionRepository = $optionRepository;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -82,13 +93,21 @@ class AdvsController extends AdminController
|
||||
'href' => '/advs/edit_advs/{entry.id}',
|
||||
'text' => "<font class='hidden-xs-down'>" . trans('streams::button.edit') . "</font>",
|
||||
],
|
||||
'change_owner' => [
|
||||
'data-toggle' => 'modal',
|
||||
'data-target' => '#modal',
|
||||
'text' => "<font class='hidden-xs-down'>" . trans('visiosoft.module.advs::button.change_owner') . "</font>",
|
||||
'icon' => 'fa fa-users',
|
||||
'href' => 'admin/advs-users/choose/{entry.id}',
|
||||
]
|
||||
'settings' => [
|
||||
'text' => false,
|
||||
'href' => false,
|
||||
'dropdown' => [
|
||||
'change_owner' => [
|
||||
'data-toggle' => 'modal',
|
||||
'data-target' => '#modal',
|
||||
'text' => trans('visiosoft.module.advs::button.change_owner'),
|
||||
'href' => 'admin/advs-users/choose/{entry.id}',
|
||||
],
|
||||
'replicate' => [
|
||||
'text' => 'Replicate',
|
||||
],
|
||||
],
|
||||
],
|
||||
]);
|
||||
|
||||
if ($this->model->is_enabled('recommendedads')) {
|
||||
@ -245,6 +264,68 @@ class AdvsController extends AdminController
|
||||
return back();
|
||||
}
|
||||
|
||||
public function replicate($advID)
|
||||
{
|
||||
try {
|
||||
$adv = $this->advRepository->find($advID);
|
||||
if (!$adv) {
|
||||
throw new \Exception(trans('visiosoft.module.advs::message.ad_doesnt_exist'));
|
||||
} else {
|
||||
// Replicate ad
|
||||
$adv = $adv->toArray();
|
||||
unset(
|
||||
$adv['id'],
|
||||
$adv['sort_order'],
|
||||
$adv['cover_photo'],
|
||||
$adv['locale'],
|
||||
$adv['name'],
|
||||
$adv['advs_desc']
|
||||
);
|
||||
$newAdv = $this->advRepository->create(array_merge($adv, [
|
||||
'slug' => $adv['slug'] . '_' . time(),
|
||||
]));
|
||||
|
||||
// Replicate ad translations
|
||||
$advTranslations = $this->advsEntryTranslationsModel->newQuery()->where('entry_id', $advID)->get();
|
||||
$translations = array();
|
||||
foreach ($advTranslations as $advTranslation) {
|
||||
$translations[$advTranslation->locale] = [
|
||||
'name' => $advTranslation->name,
|
||||
'advs_desc' => $advTranslation->advs_desc,
|
||||
];
|
||||
}
|
||||
$newAdv->update($translations);
|
||||
|
||||
// Replicate ad options
|
||||
$advOptions = $this->optionRepository->newQuery()->where('adv_id', $advID)->get();
|
||||
foreach ($advOptions as $advOption) {
|
||||
$newAdvOption = $advOption->replicate();
|
||||
$newAdvOption->adv_id = $newAdv->id;
|
||||
$newAdvOption->save();
|
||||
}
|
||||
|
||||
// Replicate ad custom fields
|
||||
$advCustomFields = $this->model->is_enabled('customfields');
|
||||
if ($advCustomFields) {
|
||||
$advCustomFields = app('Visiosoft\CustomfieldsModule\CustomFieldAdv\Contract\CustomFieldAdvRepositoryInterface')
|
||||
->newQuery()->where('parent_adv_id', $advID)->get();
|
||||
foreach ($advCustomFields as $advCustomField) {
|
||||
$newaAdvCustomField = $advCustomField->replicate();
|
||||
$newaAdvCustomField->parent_adv_id = $newAdv->id;
|
||||
$newaAdvCustomField->save();
|
||||
}
|
||||
}
|
||||
|
||||
$this->messages->success(trans('visiosoft.module.advs::message.replicated_success'));
|
||||
}
|
||||
|
||||
return redirect('admin/advs');
|
||||
} catch (\Exception $e) {
|
||||
$this->messages->error($e->getMessage());
|
||||
return redirect('admin/advs');
|
||||
}
|
||||
}
|
||||
|
||||
public function assetsClear(Filesystem $files, Application $application, Request $request)
|
||||
{
|
||||
$directory = 'assets';
|
||||
|
||||
@ -999,18 +999,22 @@ class AdvsController extends PublicController
|
||||
|
||||
public function addCart(Request $request)
|
||||
{
|
||||
$id = $request->id;
|
||||
$quantity = $request->quantity;
|
||||
$name = $request->name;
|
||||
$thisModel = new AdvModel();
|
||||
$adv = $thisModel->isAdv($id);
|
||||
$response = array();
|
||||
if ($adv) {
|
||||
$cart = $thisModel->addCart($adv, $quantity, $name);
|
||||
$response['status'] = "success";
|
||||
if (\auth()->check()) {
|
||||
$id = $request->id;
|
||||
$quantity = $request->quantity;
|
||||
$name = $request->name;
|
||||
$thisModel = new AdvModel();
|
||||
$adv = $thisModel->isAdv($id);
|
||||
$response = array();
|
||||
if ($adv) {
|
||||
$cart = $thisModel->addCart($adv, $quantity, $name);
|
||||
$response['status'] = "success";
|
||||
} else {
|
||||
$response['status'] = "error";
|
||||
$response['msg'] = trans('visiosoft.module.advs::message.error_added_cart');
|
||||
}
|
||||
} else {
|
||||
$response['status'] = "error";
|
||||
$response['msg'] = trans('visiosoft.module.advs::message.error_added_cart');
|
||||
$response['status'] = "guest";
|
||||
}
|
||||
return $response;
|
||||
}
|
||||
|
||||
@ -60,7 +60,7 @@
|
||||
<div class="tab-content py-3 px-3 px-sm-0" id="nav-tabContent">
|
||||
<div class="tab-pane fade show active" id="nav-profile" role="tabpanel"
|
||||
aria-labelledby="nav-profile-tab">
|
||||
<div class="col-12">
|
||||
<div>
|
||||
{% set userForm = form('userProfile').entry(user.id).get() %}
|
||||
{{ userForm.open()|raw }}
|
||||
<div class="form-group">
|
||||
@ -85,12 +85,14 @@
|
||||
{{ userForm.actions|raw }}
|
||||
</div>
|
||||
{{ userForm.close()|raw }}
|
||||
<div class="col-12">
|
||||
<div class="d-flex align-items-center justify-content-between flex-wrap">
|
||||
<label class="text-muted">
|
||||
{{ trans('visiosoft.module.profile::message.disable_account') }}
|
||||
</label>
|
||||
<button type="button" class="btn btn-danger float-right"
|
||||
onclick="window.location.href='/profile/closeAccount'">{{ trans("visiosoft.module.profile::field.disable_account.name") }}</button>
|
||||
<button type="button" class="btn btn-danger"
|
||||
onclick="window.location.href='/profile/closeAccount'">
|
||||
{{ trans("visiosoft.module.profile::field.disable_account.name") }}
|
||||
</button>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user