mirror of
https://github.com/openclassify/openclassify.git
synced 2026-02-09 06:46:08 -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',
|
'choose_user' => 'Choose a user',
|
||||||
'owner_updated_successfully' => 'The Owner Has Been Updated Successfully!',
|
'owner_updated_successfully' => 'The Owner Has Been Updated Successfully!',
|
||||||
'no_add_found' => 'No Ad Found!',
|
'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\Streams\Platform\Ui\Table\TableBuilder;
|
||||||
use Anomaly\UsersModule\UsersModule;
|
use Anomaly\UsersModule\UsersModule;
|
||||||
use Illuminate\Database\Eloquent\Builder;
|
use Illuminate\Database\Eloquent\Builder;
|
||||||
|
use Visiosoft\AdvsModule\Adv\Table\Filter\NameDescFilterQuery;
|
||||||
use Visiosoft\AdvsModule\Adv\Table\Filter\UserFilterQuery;
|
use Visiosoft\AdvsModule\Adv\Table\Filter\UserFilterQuery;
|
||||||
use Visiosoft\AdvsModule\Adv\Table\Handler\AdvHandler;
|
use Visiosoft\AdvsModule\Adv\Table\Handler\AdvHandler;
|
||||||
use Visiosoft\AdvsModule\Adv\Table\Views\All;
|
use Visiosoft\AdvsModule\Adv\Table\Views\All;
|
||||||
@ -40,10 +41,9 @@ class AdvTableBuilder extends TableBuilder
|
|||||||
*/
|
*/
|
||||||
protected $filters = [
|
protected $filters = [
|
||||||
'search' => [
|
'search' => [
|
||||||
'fields' => [
|
'filter' => 'input',
|
||||||
'name',
|
'placeholder' => 'visiosoft.module.advs::field.search',
|
||||||
'advs_desc',
|
'query' => NameDescFilterQuery::class,
|
||||||
]
|
|
||||||
],
|
],
|
||||||
'country',
|
'country',
|
||||||
'id' => [
|
'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\SettingsModule\Setting\Contract\SettingRepositoryInterface;
|
||||||
use Anomaly\Streams\Platform\Application\Application;
|
use Anomaly\Streams\Platform\Application\Application;
|
||||||
use Anomaly\Streams\Platform\Entry\Contract\EntryInterface;
|
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\Streams\Platform\Model\Cats\CatsCategoryEntryModel;
|
||||||
use Anomaly\UsersModule\User\Contract\UserRepositoryInterface;
|
use Anomaly\UsersModule\User\Contract\UserRepositoryInterface;
|
||||||
use Anomaly\UsersModule\User\UserModel;
|
use Anomaly\UsersModule\User\UserModel;
|
||||||
use Illuminate\Filesystem\Filesystem;
|
use Illuminate\Filesystem\Filesystem;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use Illuminate\Support\Facades\DB;
|
use Illuminate\Support\Facades\DB;
|
||||||
|
use Visiosoft\AdvsModule\Adv\Contract\AdvRepositoryInterface;
|
||||||
use Visiosoft\AdvsModule\Adv\Table\Filter\CategoryFilterQuery;
|
use Visiosoft\AdvsModule\Adv\Table\Filter\CategoryFilterQuery;
|
||||||
use Visiosoft\AdvsModule\Adv\Table\Filter\CityFilterQuery;
|
use Visiosoft\AdvsModule\Adv\Table\Filter\CityFilterQuery;
|
||||||
use Visiosoft\AdvsModule\Adv\Table\Filter\StatusFilterQuery;
|
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\Form\AdvFormBuilder;
|
||||||
use Visiosoft\AdvsModule\Adv\Table\AdvTableBuilder;
|
use Visiosoft\AdvsModule\Adv\Table\AdvTableBuilder;
|
||||||
use Anomaly\Streams\Platform\Http\Controller\AdminController;
|
use Anomaly\Streams\Platform\Http\Controller\AdminController;
|
||||||
|
use Visiosoft\AdvsModule\Option\Contract\OptionRepositoryInterface;
|
||||||
use Visiosoft\CatsModule\Category\CategoryModel;
|
use Visiosoft\CatsModule\Category\CategoryModel;
|
||||||
use Visiosoft\LocationModule\City\CityModel;
|
use Visiosoft\LocationModule\City\CityModel;
|
||||||
use Visiosoft\AlgoliaModule\Search\SearchModel;
|
use Visiosoft\AlgoliaModule\Search\SearchModel;
|
||||||
use Illuminate\Contracts\Events\Dispatcher;
|
|
||||||
|
|
||||||
|
|
||||||
class AdvsController extends AdminController
|
class AdvsController extends AdminController
|
||||||
{
|
{
|
||||||
private $model;
|
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();
|
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}',
|
'href' => '/advs/edit_advs/{entry.id}',
|
||||||
'text' => "<font class='hidden-xs-down'>" . trans('streams::button.edit') . "</font>",
|
'text' => "<font class='hidden-xs-down'>" . trans('streams::button.edit') . "</font>",
|
||||||
],
|
],
|
||||||
'change_owner' => [
|
'settings' => [
|
||||||
'data-toggle' => 'modal',
|
'text' => false,
|
||||||
'data-target' => '#modal',
|
'href' => false,
|
||||||
'text' => "<font class='hidden-xs-down'>" . trans('visiosoft.module.advs::button.change_owner') . "</font>",
|
'dropdown' => [
|
||||||
'icon' => 'fa fa-users',
|
'change_owner' => [
|
||||||
'href' => 'admin/advs-users/choose/{entry.id}',
|
'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')) {
|
if ($this->model->is_enabled('recommendedads')) {
|
||||||
@ -245,6 +264,68 @@ class AdvsController extends AdminController
|
|||||||
return back();
|
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)
|
public function assetsClear(Filesystem $files, Application $application, Request $request)
|
||||||
{
|
{
|
||||||
$directory = 'assets';
|
$directory = 'assets';
|
||||||
|
|||||||
@ -999,18 +999,22 @@ class AdvsController extends PublicController
|
|||||||
|
|
||||||
public function addCart(Request $request)
|
public function addCart(Request $request)
|
||||||
{
|
{
|
||||||
$id = $request->id;
|
if (\auth()->check()) {
|
||||||
$quantity = $request->quantity;
|
$id = $request->id;
|
||||||
$name = $request->name;
|
$quantity = $request->quantity;
|
||||||
$thisModel = new AdvModel();
|
$name = $request->name;
|
||||||
$adv = $thisModel->isAdv($id);
|
$thisModel = new AdvModel();
|
||||||
$response = array();
|
$adv = $thisModel->isAdv($id);
|
||||||
if ($adv) {
|
$response = array();
|
||||||
$cart = $thisModel->addCart($adv, $quantity, $name);
|
if ($adv) {
|
||||||
$response['status'] = "success";
|
$cart = $thisModel->addCart($adv, $quantity, $name);
|
||||||
|
$response['status'] = "success";
|
||||||
|
} else {
|
||||||
|
$response['status'] = "error";
|
||||||
|
$response['msg'] = trans('visiosoft.module.advs::message.error_added_cart');
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
$response['status'] = "error";
|
$response['status'] = "guest";
|
||||||
$response['msg'] = trans('visiosoft.module.advs::message.error_added_cart');
|
|
||||||
}
|
}
|
||||||
return $response;
|
return $response;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -60,7 +60,7 @@
|
|||||||
<div class="tab-content py-3 px-3 px-sm-0" id="nav-tabContent">
|
<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"
|
<div class="tab-pane fade show active" id="nav-profile" role="tabpanel"
|
||||||
aria-labelledby="nav-profile-tab">
|
aria-labelledby="nav-profile-tab">
|
||||||
<div class="col-12">
|
<div>
|
||||||
{% set userForm = form('userProfile').entry(user.id).get() %}
|
{% set userForm = form('userProfile').entry(user.id).get() %}
|
||||||
{{ userForm.open()|raw }}
|
{{ userForm.open()|raw }}
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
@ -85,12 +85,14 @@
|
|||||||
{{ userForm.actions|raw }}
|
{{ userForm.actions|raw }}
|
||||||
</div>
|
</div>
|
||||||
{{ userForm.close()|raw }}
|
{{ userForm.close()|raw }}
|
||||||
<div class="col-12">
|
<div class="d-flex align-items-center justify-content-between flex-wrap">
|
||||||
<label class="text-muted">
|
<label class="text-muted">
|
||||||
{{ trans('visiosoft.module.profile::message.disable_account') }}
|
{{ trans('visiosoft.module.profile::message.disable_account') }}
|
||||||
</label>
|
</label>
|
||||||
<button type="button" class="btn btn-danger float-right"
|
<button type="button" class="btn btn-danger"
|
||||||
onclick="window.location.href='/profile/closeAccount'">{{ trans("visiosoft.module.profile::field.disable_account.name") }}</button>
|
onclick="window.location.href='/profile/closeAccount'">
|
||||||
|
{{ trans("visiosoft.module.profile::field.disable_account.name") }}
|
||||||
|
</button>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user