diff --git a/addons/default/visiosoft/advs-module/resources/js/list.js b/addons/default/visiosoft/advs-module/resources/js/list.js
index ecf5f4b07..a96ace789 100644
--- a/addons/default/visiosoft/advs-module/resources/js/list.js
+++ b/addons/default/visiosoft/advs-module/resources/js/list.js
@@ -3,7 +3,7 @@ var filter = {};
filter.checkUser = () => {
$.ajax({
type: 'get',
- url: '/check_user',
+ url: '/check-user',
success: function (response) {
if (response.success == true) {
$('#search-fav-modal').modal('toggle');
diff --git a/addons/default/visiosoft/advs-module/resources/views/ad-detail/partials/breadcrumb.twig b/addons/default/visiosoft/advs-module/resources/views/ad-detail/partials/breadcrumb.twig
index e334cc965..d2211986f 100644
--- a/addons/default/visiosoft/advs-module/resources/views/ad-detail/partials/breadcrumb.twig
+++ b/addons/default/visiosoft/advs-module/resources/views/ad-detail/partials/breadcrumb.twig
@@ -2,7 +2,7 @@
{% for cat in categories %}
-
- {{ cat['name'] }}
+ {{ cat['name'] }}
{% endfor %}
diff --git a/addons/default/visiosoft/advs-module/resources/views/ad-detail/partials/detail.twig b/addons/default/visiosoft/advs-module/resources/views/ad-detail/partials/detail.twig
index efd963ad9..93210a81b 100644
--- a/addons/default/visiosoft/advs-module/resources/views/ad-detail/partials/detail.twig
+++ b/addons/default/visiosoft/advs-module/resources/views/ad-detail/partials/detail.twig
@@ -30,7 +30,7 @@
{{ trans('visiosoft.module.advs::field.offered_by') }}:
{{ adv.first_name }} {{ adv.last_name }}
{{ addBlock('ad-detail/seller/action',{'seller_id':adv.owner_id})|raw }}
@@ -52,8 +52,9 @@
{% if adv.isCorporate == 2 %}
{% endif %}
diff --git a/addons/default/visiosoft/advs-module/resources/views/list/map.twig b/addons/default/visiosoft/advs-module/resources/views/list/map.twig
index 391f56f13..5653721a1 100644
--- a/addons/default/visiosoft/advs-module/resources/views/list/map.twig
+++ b/addons/default/visiosoft/advs-module/resources/views/list/map.twig
@@ -39,7 +39,7 @@
$.ajax({
async: false,
type: 'GET',
- url: '{{ url('mapJson') }}',
+ url: '{{ url('map-json') }}',
data: QueryString(window.location.href),
success: function (data) {
console.log(data)
diff --git a/addons/default/visiosoft/advs-module/src/Adv/AdvRepository.php b/addons/default/visiosoft/advs-module/src/Adv/AdvRepository.php
index ae6dd403b..98eaf9406 100644
--- a/addons/default/visiosoft/advs-module/src/Adv/AdvRepository.php
+++ b/addons/default/visiosoft/advs-module/src/Adv/AdvRepository.php
@@ -439,9 +439,9 @@ class AdvRepository extends EntryRepository implements AdvRepositoryInterface
public function getCategoriesWithAdID($id)
{
- $adv = $this->model->find($id);
+ $adv = $this->find($id);
- if (!is_null($adv)) {
+ if ($adv) {
$categories = array();
foreach ($adv->toArray() as $key => $field) {
if (preg_match('/cat\d/', $key) and !is_null($field)) {
@@ -450,6 +450,7 @@ class AdvRepository extends EntryRepository implements AdvRepositoryInterface
}
return $categories;
}
+
return null;
}
diff --git a/addons/default/visiosoft/advs-module/src/Adv/Table/AdvTableBuilder.php b/addons/default/visiosoft/advs-module/src/Adv/Table/AdvTableBuilder.php
index f85f0db79..00c1b0260 100644
--- a/addons/default/visiosoft/advs-module/src/Adv/Table/AdvTableBuilder.php
+++ b/addons/default/visiosoft/advs-module/src/Adv/Table/AdvTableBuilder.php
@@ -107,6 +107,13 @@ class AdvTableBuilder extends TableBuilder
*
* @var array
*/
- protected $assets = [];
+ protected $assets = [
+ 'scripts.js' => [
+ 'visiosoft.module.advs::js/list.js',
+ ],
+ 'styles.css' => [
+ 'visiosoft.module.advs::css/custom.css',
+ ]
+ ];
}
diff --git a/addons/default/visiosoft/advs-module/src/AdvsModule.php b/addons/default/visiosoft/advs-module/src/AdvsModule.php
index 0eda5defc..b6f21ca57 100644
--- a/addons/default/visiosoft/advs-module/src/AdvsModule.php
+++ b/addons/default/visiosoft/advs-module/src/AdvsModule.php
@@ -41,17 +41,6 @@ class AdvsModule extends Module
'title' => 'visiosoft.module.advs::section.assets_clear.name',
'href' => '/admin/assets/clear',
]
- // 'custom_fields' => [
- // 'buttons' => [
- // 'new_custom_field',
- // ],
- // ],
- // 'custom_field_advs' => [
- // // 'buttons' => [
- // // 'new_custom_field_adv',
- // // ],
- // ],
-
];
}
diff --git a/addons/default/visiosoft/advs-module/src/AdvsModuleServiceProvider.php b/addons/default/visiosoft/advs-module/src/AdvsModuleServiceProvider.php
index b1eedcb8d..12197ce1b 100644
--- a/addons/default/visiosoft/advs-module/src/AdvsModuleServiceProvider.php
+++ b/addons/default/visiosoft/advs-module/src/AdvsModuleServiceProvider.php
@@ -20,8 +20,6 @@ use Visiosoft\LocationModule\Village\VillageRepository;
use Visiosoft\LocationModule\Village\VillageModel;
use Visiosoft\CatsModule\Category\Contract\CategoryRepositoryInterface;
use Visiosoft\CatsModule\Category\CategoryRepository;
-use Visiosoft\CatsModule\Category\CategoryModel;
-use Illuminate\Routing\Router;
use Visiosoft\LocationModule\Country\Contract\CountryRepositoryInterface;
use Visiosoft\LocationModule\Country\CountryRepository;
@@ -37,46 +35,13 @@ class AdvsModuleServiceProvider extends AddonServiceProvider
AdvsModulePlugin::class,
];
- /**
- * The addon Artisan commands.
- *
- * @type array|null
- */
- protected $commands = [];
-
- /**
- * The addon's scheduled commands.
- *
- * @type array|null
- */
- protected $schedules = [];
-
- /**
- * The addon API routes.
- *
- * @type array|null
- */
- protected $api = [];
-
/**
* The addon routes.
*
* @type array|null
*/
protected $routes = [
- 'admin/advs/advs' => [
- 'as' => 'visiosoft.module.advs::admin_advs',
- 'uses' => 'Visiosoft\AdvsModule\Http\Controller\Admin\AdvsController@index',
- ],
- 'admin/advs/advs/create' => 'Visiosoft\AdvsModule\Http\Controller\Admin\AdvsController@create',
- 'admin/advs/advs/edit/{id}' => [
- 'middleware' => 'auth',
- 'uses' => 'Visiosoft\AdvsModule\Http\Controller\Admin\AdvsController@edit'
- ],
- 'admin/advs/village' => 'Visiosoft\AdvsModule\Http\Controller\Admin\VillageController@index',
- 'admin/advs/village/create' => 'Visiosoft\AdvsModule\Http\Controller\Admin\VillageController@create',
- 'admin/advs/village/edit/{id}' => 'Visiosoft\AdvsModule\Http\Controller\Admin\VillageController@edit',
- 'categories/checkparent/{id}' => 'Visiosoft\AdvsModule\Http\Controller\advsController@checkParentCat',
+ // Admin routes
'admin/advs/ajax' => [
'as' => 'visiosoft.module.advs::ajax',
'uses' => 'Visiosoft\AdvsModule\Http\Controller\AjaxController@locations',
@@ -94,8 +59,6 @@ class AdvsModuleServiceProvider extends AddonServiceProvider
'admin/advs' => 'Visiosoft\AdvsModule\Http\Controller\Admin\AdvsController@index',
// User choose modal
'admin/advs-users/choose/{advId}' => 'Visiosoft\AdvsModule\Http\Controller\Admin\AdvsController@choose',
- 'admin/advs/create' => 'Visiosoft\AdvsModule\Http\Controller\Admin\AdvsController@create',
- 'admin/advs/edit/{id}' => 'Visiosoft\AdvsModule\Http\Controller\Admin\AdvsController@edit',
'admin/advs/list' => [
'as' => 'visiosoft.module.advs::admin-list',
'uses' => 'Visiosoft\AdvsModule\Http\Controller\Admin\AdvsController@manage'
@@ -105,15 +68,6 @@ class AdvsModuleServiceProvider extends AddonServiceProvider
'as' => 'visiosoft.module.advs::list',
'uses' => 'Visiosoft\AdvsModule\Http\Controller\advsController@index'
],
- 'advs/list?user={id}' => [
- 'as' => 'visiosoft.module.advs::list_user_ad',
- 'uses' => 'Visiosoft\AdvsModule\Http\Controller\advsController@index',
- ],
- 'advs/list?cat={id}' => [
- 'as' => 'visiosoft.module.advs::list_cat',
- 'uses' => 'Visiosoft\AdvsModule\Http\Controller\advsController@index',
- ],
- 'getlocations' => 'Visiosoft\AdvsModule\Http\Controller\advsController@getLocations',
'advs/main' => 'Visiosoft\AdvsModule\Http\Controller\advsController@advsMainPage',
'advs/adv/{id}' => [
'as' => 'adv_detail_backup',
@@ -135,12 +89,6 @@ class AdvsModuleServiceProvider extends AddonServiceProvider
'as' => 'advs_preview',
'uses' => 'Visiosoft\AdvsModule\Http\Controller\advsController@preview'
],
- 'advs/map?country={country}&city[]={city}&district={districts}' => [
- 'as' => 'visiosoft.module.advs::show_ad_map_location',
- 'uses' => 'Visiosoft\AdvsModule\Http\Controller\advsController@map'
- ],
- 'advs/categories' => 'Visiosoft\AdvsModule\Http\Controller\CategoriesController@index',
- 'advs/c/{cat}' => 'Visiosoft\AdvsModule\Http\Controller\CategoriesController@listByCat',
'c/{category?}/{city?}' => [
'as' => 'adv_list_seo',
'uses' => 'Visiosoft\AdvsModule\Http\Controller\advsController@index'
@@ -148,6 +96,7 @@ class AdvsModuleServiceProvider extends AddonServiceProvider
'advs/module_active' => 'Visiosoft\AdvsModule\Http\Controller\advsController@index',
'advs/create_adv' => [
'as' => "advs::create_adv",
+ 'middleware' => "auth",
'uses' => 'Visiosoft\AdvsModule\Http\Controller\advsController@cats',
],
'advs/create_adv/post_cat' => [
@@ -156,6 +105,7 @@ class AdvsModuleServiceProvider extends AddonServiceProvider
],
'class/getcats/{id}' => 'Visiosoft\AdvsModule\Http\Controller\advsController@getCatsForNewAd',
'advs/save_adv' => [
+ 'middleware' => 'auth',
'as' => 'visiosoft.module.advs::post_cat',
'uses' => 'Visiosoft\AdvsModule\Http\Controller\advsController@store'
],
@@ -170,38 +120,13 @@ class AdvsModuleServiceProvider extends AddonServiceProvider
'uses' => 'Visiosoft\AdvsModule\Http\Controller\advsController@statusAds'
],
'routes' => 'Visiosoft\AdvsModule\Http\Controller\advsController@routes',
- 'advs/map/advs/list' => [
- 'as' => 'advs_map_list',
- 'uses' => 'Visiosoft\AdvsModule\Http\Controller\advsController@map',
- ],
- 'advs/map' => [
- 'as' => 'advs_map',
- 'uses' => 'Visiosoft\AdvsModule\Http\Controller\advsController@map',
- ],
- 'mapJson' => 'Visiosoft\AdvsModule\Http\Controller\advsController@mapJson',
+ 'map-json' => 'Visiosoft\AdvsModule\Http\Controller\advsController@mapJson',
'advs/ttr/{id}' => 'Visiosoft\PackagesModule\Http\Controller\packageFEController@advsStatusbyUser',
'advs/delete/{id}' => [
'as' => 'advs::delete',
'uses' => 'Visiosoft\AdvsModule\Http\Controller\advsController@deleteAd',
],
- 'check_user' => 'Visiosoft\AdvsModule\Http\Controller\advsController@checkUser',
'keySearch' => 'Visiosoft\AdvsModule\Http\Controller\AjaxController@keySearch',
- 'adv/addCart/{id}' => [
- 'as' => 'adv_AddCart',
- 'uses' => 'Visiosoft\AdvsModule\Http\Controller\advsController@advAddCart',
- ],
- 'ajax/StockControl' => [
- 'as' => 'adv_stock_control_ajax',
- 'uses' => 'Visiosoft\AdvsModule\Http\Controller\advsController@stockControl',
- ],
- 'ajax/addCart' => [
- 'as' => 'adv_add_cart_ajax',
- 'uses' => 'Visiosoft\AdvsModule\Http\Controller\advsController@addCart',
- ],
- 'ajax/countPhone' => [
- 'as' => 'adv_count_show_phone',
- 'uses' => 'Visiosoft\AdvsModule\Http\Controller\advsController@showPhoneCounter',
- ],
'view/{type}' => [
'as' => 'visiosoft.module.advs::view_type',
'uses' => 'Visiosoft\AdvsModule\Http\Controller\advsController@viewType',
@@ -211,13 +136,10 @@ class AdvsModuleServiceProvider extends AddonServiceProvider
'uses' => 'Visiosoft\AdvsModule\Http\Controller\Admin\AdvsController@assetsClear',
],
'adv/edit/category/{id}' => [
+ 'middleware' => 'auth',
'as' => 'adv::edit_category',
'uses' => 'Visiosoft\AdvsModule\Http\Controller\advsController@editCategoryForAd',
],
- 'ajax/getcats/{id}' => [
- 'as' => 'ajax::getCats',
- 'uses' => 'Visiosoft\AdvsModule\Http\Controller\advsController@getCats',
- ],
'ajax/getAdvs' => [
'as' => 'ajax::getAds',
@@ -247,24 +169,6 @@ class AdvsModuleServiceProvider extends AddonServiceProvider
redirectDiffrentLang::class,
];
- /**
- * Addon group middleware.
- *
- * @var array
- */
- protected $groupMiddleware = [
- //'web' => [
- // Visiosoft\AdvsModule\Http\Middleware\ExampleMiddleware::class,
- //],
- ];
-
- /**
- * Addon route middleware.
- *
- * @type array|null
- */
- protected $routeMiddleware = [];
-
/**
* The addon event listeners.
*
@@ -276,15 +180,6 @@ class AdvsModuleServiceProvider extends AddonServiceProvider
],
];
- /**
- * The addon alias bindings.
- *
- * @type array|null
- */
- protected $aliases = [
- //'Example' => Visiosoft\AdvsModule\Example::class
- ];
-
/**
* The addon class bindings.
*
@@ -296,8 +191,6 @@ class AdvsModuleServiceProvider extends AddonServiceProvider
// AdvsCustomFieldsEntryModel::class => CustomFieldModel::class,
AdvsAdvsEntryModel::class => AdvModel::class,
LocationVillageEntryModel::class => VillageModel::class,
- AdvsCategoriesEntryModel::class => CategoryModel::class,
- AdvsAdvsEntryModel::class => AdvModel::class,
'my_form' => AdvFormBuilder::class,
];
@@ -307,9 +200,6 @@ class AdvsModuleServiceProvider extends AddonServiceProvider
* @type array|null
*/
protected $singletons = [
- // CfValueRepositoryInterface::class => CfValueRepository::class,
- // CustomFieldAdvRepositoryInterface::class => CustomFieldAdvRepository::class,
- // CustomFieldRepositoryInterface::class => CustomFieldRepository::class,
AdvRepositoryInterface::class => AdvRepository::class,
VillageRepositoryInterface::class => VillageRepository::class,
CategoryRepositoryInterface::class => CategoryRepository::class,
@@ -317,15 +207,6 @@ class AdvsModuleServiceProvider extends AddonServiceProvider
OptionRepositoryInterface::class => OptionRepository::class,
];
- /**
- * Additional service providers.
- *
- * @type array|null
- */
- protected $providers = [
- //\ExamplePackage\Provider\ExampleProvider::class
- ];
-
/**
* The addon view overrides.
*
@@ -333,29 +214,8 @@ class AdvsModuleServiceProvider extends AddonServiceProvider
*/
protected $overrides = [
'streams::form/form' => 'visiosoft.module.advs::form/form',
- //'streams::errors/404' => 'module::errors/404',
- //'streams::errors/500' => 'module::errors/500',
];
- /**
- * The addon mobile-only view overrides.
- *
- * @type array|null
- */
- protected $mobile = [
- //'streams::errors/404' => 'module::mobile/errors/404',
- //'streams::errors/500' => 'module::mobile/errors/500',
- ];
-
- /**
- * Register the addon.
- */
- public function register()
- {
- // Run extra pre-boot registration logic here.
- // Use method injection or commands to bring in services.
- }
-
/**
* Boot the addon.
* @param AddonCollection $addonCollection
@@ -381,18 +241,4 @@ class AdvsModuleServiceProvider extends AddonServiceProvider
// Disable file versioning
$fileModel->disableVersioning();
}
-
- /**
- * Map additional addon routes.
- *
- * @param Router $router
- */
- // public function map(Router $router)
- // {
- // // Register dynamic routes here for example.
- // // Use method injection or commands to bring in services.
- // }
- public function map(Router $router)
- {
- }
}
diff --git a/addons/default/visiosoft/advs-module/src/Http/Controller/Admin/AdvsController.php b/addons/default/visiosoft/advs-module/src/Http/Controller/Admin/AdvsController.php
index b6c0280c0..5fb965fe3 100644
--- a/addons/default/visiosoft/advs-module/src/Http/Controller/Admin/AdvsController.php
+++ b/addons/default/visiosoft/advs-module/src/Http/Controller/Admin/AdvsController.php
@@ -1,13 +1,10 @@
model = $model;
$this->advRepository = $advRepository;
$this->advsEntryTranslationsModel = $advsEntryTranslationsModel;
$this->optionRepository = $optionRepository;
+ $this->userRepository = $userRepository;
}
/**
@@ -53,11 +50,8 @@ class AdvsController extends AdminController
* @param AdvTableBuilder $table
* @return \Symfony\Component\HttpFoundation\Response
*/
- public function index(AdvTableBuilder $table, \Anomaly\UsersModule\User\UserModel $userModel, CityModel $cityModel, CatsCategoryEntryModel $categoryModel)
+ public function index(AdvTableBuilder $table, CityModel $cityModel, CatsCategoryEntryModel $categoryModel)
{
- $table->addAsset("styles.css", "visiosoft.module.advs::css/custom.css");
- $table->addAsset('scripts.js', 'visiosoft.module.advs::js/list.js');
-
$table->addButtons([
'status' => [
'text' => function (EntryInterface $entry) {
@@ -89,10 +83,7 @@ class AdvsController extends AdminController
}
},
],
- 'edit' => [
- 'href' => '/advs/edit_advs/{entry.id}',
- 'text' => "" . trans('streams::button.edit') . "",
- ],
+
'settings' => [
'text' => false,
'href' => false,
@@ -110,19 +101,11 @@ class AdvsController extends AdminController
],
]);
- if ($this->model->is_enabled('recommendedads')) {
- $table->addButton('add_recommended', [
- 'type' => 'default',
- 'icon' => 'fa fa-gg',
- 'text' => 'Add Recommended',
- 'href' => '/admin/recommendedads/create/{entry.id}',
- ]);
- }
-
$table->setColumns([
'cover_photo' => [
'value' => function (EntryInterface $entry) {
- return "
";
+ $coverImageUrl = $this->advRepository->getModel()->AddAdsDefaultCoverImage($entry)->cover_photo;
+ return "
";
},
],
'entry.id',
@@ -130,7 +113,12 @@ class AdvsController extends AdminController
'class' => 'advs-name',
'sort_column' => 'slug',
'value' => function (EntryInterface $entry) {
- return (!is_null($entry->name)) ? " " . $entry->name . " " : "" . trans("visiosoft.module.advs::view.unfinished") . "";
+ if ($entry->name) {
+ $adLink = $this->advRepository->getModel()->getAdvDetailLinkByModel($entry, 'list');
+ return "{$entry->name}";
+ } else {
+ return "" . trans("visiosoft.module.advs::view.unfinished") . "";
+ }
},
],
'price' => [
@@ -143,11 +131,7 @@ class AdvsController extends AdminController
'class' => 'advs-country',
],
'created_by' => [
- 'value' => function (EntryInterface $entry, UserModel $userModel) {
- $user = $userModel->find($entry->created_by_id);
- if (!is_null($user))
- return $user->first_name . " " . $user->last_name;
- }
+ 'value' => 'entry.created_by.name'
],
'category' => [
'value' => function (EntryInterface $entry, CategoryModel $categoryModel) {
@@ -161,7 +145,7 @@ class AdvsController extends AdminController
$cities = $cityModel->all()->pluck('name', 'id')->all();
- $users = $userModel->newQuery()
+ $users = $this->userRepository->newQuery()
->select(DB::raw("CONCAT_WS('', first_name, ' ', last_name, ' (', gsm_phone, ' || ', email, ')') AS display_name"), 'id')
->pluck('display_name', 'id')
->toArray();
@@ -212,55 +196,29 @@ class AdvsController extends AdminController
if (empty($request->all())) {
return $this->view->make('module::admin/advs/choose', ['users' => $users->all(), 'advId' => $advId]);
} else {
- $this->model->newQuery()->find($advId)->update(['created_by_id' => $request->user_id]);
+ $this->advRepository->getModel()->newQuery()->find($advId)->update(['created_by_id' => $request->user_id]);
$this->messages->success(trans('module::message.owner_updated_successfully'));
return redirect()->back();
}
}
- /**
- * Create a new entry.
- *
- * @param AdvFormBuilder $form
- * @return \Symfony\Component\HttpFoundation\Response
- */
- public function create(AdvFormBuilder $form)
+ public function actions($id, $type)
{
- // $this->dispatch(new AddEntryFormFromRequest($form));
- // $this->dispatch(new AddAdvFormFromRequest($form));
- return $form->render();
- }
-
- /**
- * Edit an existing entry.
- *
- * @param AdvFormBuilder $form
- * @param $id
- * @return \Symfony\Component\HttpFoundation\Response
- */
- public function edit(AdvFormBuilder $form, $id)
- {
- return $form->render($id);
- }
-
- public function actions($id, $type, SettingRepositoryInterface $settings, AdvModel $advModel)
- {
-
- $ad = $advModel->where('advs_advs.id', '=', $id)->first();
+ $ad = $this->advRepository->find($id);
$ad->status = $type;
- $default_adv_publish = $settings->value('visiosoft.module.advs::default_published_time');
+ $default_adv_publish = setting_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');
//algolia Search Module
- $isActiveAlgolia = $advModel->is_enabled('algolia');
+ $isActiveAlgolia = $this->advRepository->getModel()->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
+ event(new ChangedStatusAd($ad)); //Create Notify
return back();
}
@@ -328,42 +286,34 @@ class AdvsController extends AdminController
public function assetsClear(Filesystem $files, Application $application, Request $request)
{
- $directory = 'assets';
- $files->deleteDirectory($directory = $application->getAssetsPath($directory), true);
- echo "" . "
";
- echo "
-
-
- Return Back";
- echo "
Return Admin Panel";
+ @keyframes move {
+ 0% {
+ background-position: 0 0;
+ }
+ 100% {
+ background-position: 28px 0;
+ }
+ }
+
+
+
+ ";
}
}
diff --git a/addons/default/visiosoft/advs-module/src/Http/Controller/AjaxController.php b/addons/default/visiosoft/advs-module/src/Http/Controller/AjaxController.php
index 7f88318b2..fbd872b14 100644
--- a/addons/default/visiosoft/advs-module/src/Http/Controller/AjaxController.php
+++ b/addons/default/visiosoft/advs-module/src/Http/Controller/AjaxController.php
@@ -19,9 +19,9 @@ class AjaxController extends PublicController
public function __construct(AdvModel $advModel, UserModel $userModel)
{
+ parent::__construct();
$this->adv_model = $advModel;
$this->userModel = $userModel;
- parent::__construct();
}
public function locations(Request $request)
diff --git a/addons/default/visiosoft/advs-module/src/Http/Controller/CategoriesController.php b/addons/default/visiosoft/advs-module/src/Http/Controller/CategoriesController.php
deleted file mode 100644
index 034e64b19..000000000
--- a/addons/default/visiosoft/advs-module/src/Http/Controller/CategoriesController.php
+++ /dev/null
@@ -1,32 +0,0 @@
-where('cat1', $cat)
- ->orwhere('cat2', $cat)
- ->orwhere('cat3', $cat)
- ->orwhere('cat4', $cat)
- ->orwhere('cat5', $cat)
- ->orwhere('cat6', $cat)
- ->orwhere('cat7', $cat)
- ->leftJoin('users_users as u1', 'advs_advs.created_by_id', '=', 'u1.id')
- ->leftJoin('advs_advs_translations as t1', 'advs_advs.id', '=', 't1.id')
- ->select('advs_advs.*','u1.username as owner', 't1.name as name')
- ->get();
-
- foreach ($advs as $adv) {
- if (strpos($adv->cover_photo, 'http') !== 0 && strpos($adv->cover_photo, '/') !== 0) {
- $adv->cover_photo = "/$adv->cover_photo";
- }
- }
-
- return $this->view->make('visiosoft.module.advs::list/list', compact('advs'));
- }
-}
diff --git a/addons/default/visiosoft/advs-module/src/Http/Controller/advsController.php b/addons/default/visiosoft/advs-module/src/Http/Controller/advsController.php
index 3d28a3ee4..781795d1f 100644
--- a/addons/default/visiosoft/advs-module/src/Http/Controller/advsController.php
+++ b/addons/default/visiosoft/advs-module/src/Http/Controller/advsController.php
@@ -3,14 +3,11 @@
use Anomaly\SettingsModule\Setting\Contract\SettingRepositoryInterface;
use Anomaly\Streams\Platform\Http\Controller\PublicController;
use Anomaly\Streams\Platform\Model\Advs\AdvsAdvsEntryModel;
-use Anomaly\Streams\Platform\Model\Advs\PurchasePurchaseEntryModel;
use Anomaly\Streams\Platform\Model\Complaints\ComplaintsComplainTypesEntryModel;
-use Anomaly\Streams\Platform\Model\Options\OptionsAdvertisementEntryModel;
use Anomaly\UsersModule\User\Contract\UserRepositoryInterface;
use Visiosoft\AdvsModule\Adv\Command\appendRequestURL;
use Visiosoft\AdvsModule\Adv\Event\ChangedStatusAd;
use Visiosoft\AdvsModule\Adv\Event\CreatedAd;
-use Visiosoft\AdvsModule\Adv\Event\showAdPhone;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Cookie;
@@ -29,22 +26,18 @@ use Visiosoft\LocationModule\City\CityModel;
use Visiosoft\AlgoliaModule\Search\SearchModel;
use Visiosoft\AlgoliatestModule\Http\Controller\Admin\IndexController;
use Visiosoft\CloudinaryModule\Video\VideoModel;
-use Visiosoft\FavsModule\Http\Controller\FavsController;
use Visiosoft\LocationModule\District\DistrictModel;
use Visiosoft\LocationModule\Neighborhood\NeighborhoodModel;
use Visiosoft\LocationModule\Village\VillageModel;
-use Visiosoft\PackagesModule\Http\Controller\PackageFEController;
use Visiosoft\AdvsModule\Adv\Contract\AdvRepositoryInterface;
use Visiosoft\CatsModule\Category\Contract\CategoryRepositoryInterface;
use Visiosoft\LocationModule\Country\Contract\CountryRepositoryInterface;
use Anomaly\Streams\Platform\Message\MessageBag;
use Visiosoft\PackagesModule\Package\PackageModel;
-
use Illuminate\Contracts\Events\Dispatcher;
use Visiosoft\QrcontactModule\Qr\QrModel;
use Visiosoft\StoreModule\Ad\AdModel;
-
class AdvsController extends PublicController
{
private $userRepository;
@@ -101,6 +94,8 @@ class AdvsController extends PublicController
Request $request
)
{
+ parent::__construct();
+
$this->userRepository = $userRepository;
$this->adv_model = $advModel;
@@ -126,14 +121,9 @@ class AdvsController extends PublicController
$this->requestHttp = $request;
- parent::__construct();
$this->optionRepository = $optionRepository;
}
-
- /**
- * @return \Illuminate\Contracts\View\View|mixed
- */
public function index($category = null, $city = null)
{
$customParameters = array();
@@ -463,26 +453,6 @@ class AdvsController extends PublicController
compact('adv', 'categories', 'features', 'isActiveDopings', 'options'));
}
- public function getLocations()
- {
- $table = $this->requestHttp->table;
- $id = $this->requestHttp->id;
- $db = $this->requestHttp->typeDb;
-
- $location = "";
- if ($table == "cities") {
- $location = $this->city_model->query()->where($db, $id)->get();
- } elseif ($table == "districts") {
- $location = $this->district_model->query()->whereIn($db, $id)->get();
- } elseif ($table == "neighborhoods") {
- $location = $this->neighborhood_model->query()->where($db, $id)->get();
- } elseif ($table == "village") {
- $location = $this->village_model->query()->where($db, $id)->get();
- }
-
- return $location;
- }
-
public function deleteAd(AdvRepositoryInterface $advs, $id)
{
$ad = $this->adv_model->find($id);
@@ -499,18 +469,12 @@ class AdvsController extends PublicController
return back();
}
- public function getCats($id)
- {
- return $this->category_repository->getSubCatById($id);
- }
-
public function getCatsForNewAd($id)
{
-
if ($this->adv_model->is_enabled('packages')) {
$cats = app('Visiosoft\PackagesModule\Http\Controller\PackageFEController')->AdLimitForCategorySelection($id);
} else {
- $cats = $this->getCats($id);
+ $cats = $this->category_repository->getSubCatById($id);
if (empty($cats->toArray())) {
$cats = trans('visiosoft.module.advs::message.create_ad_with_post_cat');
@@ -548,87 +512,76 @@ class AdvsController extends PublicController
'request', 'formBuilder', 'cats_d', 'custom_fields'));
}
- public function store
- (
+ public function store(
AdvFormBuilder $form,
MessageBag $messages,
- Request $request,
- SettingRepositoryInterface $settings,
- AdvRepositoryInterface $advRepository,
- CategoryRepositoryInterface $categoryRepository,
- Dispatcher $events,
- AdvModel $advModel,
- AdressRepositoryInterface $address,
- CategoryModel $categoryModel
+ AdressRepositoryInterface $address
)
{
- if (!Auth::user()) {
- redirect('/login?redirect=' . url()->current())->send();
- }
$messages->pull('error');
- if ($request->action == "update") {
- $error = $form->build($request->update_id)->validate()->getFormErrors()->getMessages();
+ if (\request()->action == "update") {
+ $error = $form->build(\request()->update_id)->validate()->getFormErrors()->getMessages();
if (!empty($error)) {
return $this->redirect->back();
}
/* Update Adv */
- $adv = AdvsAdvsEntryModel::find($request->update_id);
+ $adv = AdvsAdvsEntryModel::find(\request()->update_id);
- if ($advModel->is_enabled('packages') and $adv->slug == "") {
- $cat = app('Visiosoft\PackagesModule\Http\Controller\PackageFEController')->AdLimitForNewAd($request);
+ if ($this->adv_repository->getModel()->is_enabled('packages') and $adv->slug == "") {
+ $cat = app('Visiosoft\PackagesModule\Http\Controller\PackageFEController')->AdLimitForNewAd(\request());
if (!is_null($cat)) {
return redirect('/');
}
}
// Create options
- $deletedOptions = $request->deleted_options;
- $newOptions = $request->new_options;
+ $deletedOptions = \request()->deleted_options;
+ $newOptions = \request()->new_options;
if (!empty($deletedOptions)) {
- $deletedOptions = explode(',', $request->deleted_options);
+ $deletedOptions = explode(',', \request()->deleted_options);
$this->optionRepository->newQuery()
->whereIn('id', $deletedOptions)
- ->where('adv_id', $request->update_id)
+ ->where('adv_id', \request()->update_id)
->delete();
}
if (!empty($newOptions)) {
- $newOptions = explode(',', $request->new_options);
+ $newOptions = explode(',', \request()->new_options);
foreach ($newOptions as $option) {
$this->optionRepository->create([
'name' => $option,
- 'adv_id' => $request->update_id,
+ 'adv_id' => \request()->update_id,
]);
}
}
- $adv->is_get_adv = $request->is_get_adv;
+ $adv->is_get_adv = \request()->is_get_adv;
$adv->save();
//algolia Search Module
- $isActiveAlgolia = $advModel->is_enabled('algolia');
+ $isActiveAlgolia = $this->adv_repository->getModel()->is_enabled('algolia');
if ($isActiveAlgolia) {
$algolia = new SearchModel();
if ($adv->slug == "") {
- $algolia->saveAlgolia($adv->toArray(), $settings);
+ $algolia->saveAlgolia($adv->toArray());
} else {
- $algolia->updateAlgolia($request->toArray(), $settings);
+ $algolia->updateAlgolia(\request()->toArray());
}
}
//Cloudinary Module
- $isActiveCloudinary = $advModel->is_enabled('cloudinary');
+ $isActiveCloudinary = $this->adv_repository->getModel()->is_enabled('cloudinary');
if ($isActiveCloudinary) {
$CloudinaryModel = new VideoModel();
- $CloudinaryModel->updateRequest($request);
+ $CloudinaryModel->updateRequest(\request());
- if ($request->url != "") {
- $adv->cover_photo = "https://res.cloudinary.com/" . $request->cloudName . "/video/upload/w_400,e_loop/" .
- $request->uploadKey . "/" . $request->filename . "gif";
+ if (\request()->url != "") {
+ $adv->cover_photo = "https://res.cloudinary.com/" . \request()->cloudName . "/video/upload/w_400,e_loop/" .
+ \request()->uploadKey . "/" . \request()->filename . "gif";
$adv->save();
}
}
if ($this->adv_model->is_enabled('customfields')) {
- app('Visiosoft\CustomfieldsModule\Http\Controller\cfController')->store($adv, $request);
+ app('Visiosoft\CustomfieldsModule\Http\Controller\cfController')->store($adv, \request());
}
// Auto approve
@@ -641,8 +594,8 @@ class AdvsController extends PublicController
]);
}
- $form->render($request->update_id);
- $adv = $this->adv_repository->find($request->update_id);
+ $form->render(\request()->update_id);
+ $adv = $this->adv_repository->find(\request()->update_id);
if ($this->request->address_id != "") {
$address = $address->find($this->request->address_id);
@@ -654,35 +607,35 @@ class AdvsController extends PublicController
$adv->save();
}
$post = $form->getPostData();
- $post['id'] = $request->update_id;
- $events->dispatch(new priceChange($post));//price history
- if ($request->url == "") {
- $advRepository->cover_image_update($adv);
+ $post['id'] = \request()->update_id;
+ event(new priceChange($post));
+ if (\request()->url == "") {
+ $this->adv_repository->cover_image_update($adv);
}
if ($form->hasFormErrors()) {
- $cats = $request->toArray();
+ $cats = \request()->toArray();
$cats_d = array();
foreach ($cats as $para => $value) {
if (substr($para, 0, 3) === "cat") {
$id = $cats[$para];
- $cat = $categoryRepository->getSingleCat($id);
+ $cat = $this->category_repository->getSingleCat($id);
if ($cat != null) {
$cats_d[$para] = $cat->name;
}
}
}
- return redirect('/advs/edit_advs/' . $request->update_id)->with('cats_d', $cats_d)->with('request', $request);
+ return redirect('/advs/edit_advs/' . \request()->update_id)->with('cats_d', $cats_d)->with('request', \request());
}
event(new CreatedAd($adv));
- return redirect(route('advs_preview', [$request->update_id]));
+ return redirect(route('advs_preview', [\request()->update_id]));
}
/* New Create Adv */
- $request->publish_at = date('Y-m-d H:i:s');
- $all = $request->all();
+ \request()->publish_at = date('Y-m-d H:i:s');
+ $all = \request()->all();
$new = AdvModel::query()->create($all);
return redirect('/advs/edit_advs/' . $new->id);
}
@@ -745,16 +698,15 @@ 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');
+ $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') {
+ if ($type == 'pending_admin' && $auto_approved == true) {
$type = "approved";
- }
- if ($type == "approved" and $auto_approved != true) {
+ } elseif ($type == "approved" && $auto_approved != true) {
$type = "pending_admin";
}
@@ -775,293 +727,68 @@ class AdvsController extends PublicController
$isActiveAlgolia = $this->adv_model->is_enabled('algolia');
if ($isActiveAlgolia) {
$algolia = new SearchModel();
- $algolia->updateStatus($id, $type, $settings);
+ $algolia->updateStatus($id, $type);
}
$this->adv_model->statusAds($id, $type);
- event(new ChangedStatusAd($ad));//Create Notify
+
+ event(new ChangedStatusAd($ad));
+
$this->messages->success(trans('streams::message.edit_success', ['name' => 'Status']));
return back();
}
public function cats()
{
- if (!Auth::user()) {
- redirect('/login?redirect=' . url()->current())->send();
- }
- $main_cats = $this->category_repository->mainCats();
+ $mainCats = $this->category_repository->mainCats();
- return $this->view->make('visiosoft.module.advs::new-ad/post-cat', compact('main_cats'));
+ return $this->view->make('visiosoft.module.advs::new-ad/post-cat', compact('mainCats'));
}
- /**
- * @param $id
- * @return \Illuminate\Contracts\View\View|\Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector|mixed
- */
public function editCategoryForAd($id)
{
- if (!Auth::user()) {
- redirect('/login?redirect=' . url()->current())->send();
- }
-
$adv = $this->adv_model->userAdv(true)->find($id);
- if (is_null($adv)) {
+ if (!$adv) {
abort(403);
}
- if ($this->requestHttp->action == 'update') {
- $params = $this->requestHttp->all();
+ if (\request()->action == 'update') {
+ $params = \request()->all();
unset($params['action']);
for ($i = 2; $i <= 10; $i++) {
if (!isset($params['cat' . $i])) {
- $params['cat' . $i] = NULL;
+ $params['cat' . $i] = null;
}
}
$adv->update($params);
$this->messages->success(trans('visiosoft.module.advs::message.updated_category_msg'));
- return redirect('/advs/edit_advs/' . $id);
+ return redirect()->route('visiosoft.module.advs::edit_adv', [$id]);
}
$categories = $this->adv_repository->getCategoriesWithAdID($id);
- return $this->view->make('visiosoft.module.advs::new-ad/edit-cat', compact('id', 'adv', 'categories'));
-
+ return $this->view->make(
+ 'visiosoft.module.advs::new-ad/edit-cat',
+ compact('id', 'adv', 'categories')
+ );
}
- public function login()
+ public function mapJson()
{
- if (auth()->check()) {
- return $this->redirect->to($this->request->get('redirect', '/'));
- }
-
- $urlPrev = str_replace(url('/'), '', url()->previous());
-
- return $this->view->make('theme::login', compact('urlPrev'));
- }
-
- public function register()
- {
-
- if (auth()->check()) {
- return redirect('/');
- }
-
- return $this->view->make('theme::register');
- }
-
- public function passwordForgot()
- {
- if (auth()->check()) {
- return redirect('/');
- }
-
- return $this->view->make('theme::passwords/forgot');
- }
-
- public function passwordReset(Request $request)
- {
- if (auth()->check()) {
- return redirect('/');
- }
- $code = $request->email;
- return $this->view->make('theme::passwords/reset', compact('code'));
- }
-
- public function homePage(CategoryRepositoryInterface $repository)
- {
- $cats = $repository->mainCats();
-
- return $this->view->make('theme::addons/anomaly/pages-module/page', compact('cats'));
- }
-
- public function map(
- AdvRepositoryInterface $advRepository,
- CategoryRepositoryInterface $categories,
- CountryRepositoryInterface $countries,
- Request $request
- )
- {
-
- return $this->index($advRepository, $categories, $countries, $request, true);
-
- }
-
- public function mapJson(Request $request, AdvRepositoryInterface $repository)
- {
- $param = $request->toArray();
+ $param = \request()->toArray();
$customParameters = array();
- $advModel = new AdvModel();
- $advs = $repository->searchAdvs('map', $param, $customParameters);
+ $advs = $this->adv_repository->searchAdvs('map', $param, $customParameters);
foreach ($advs as $index => $ad) {
- $advs[$index]->seo_link = $advModel->getAdvDetailLinkByModel($ad, 'list');
- $advs[$index] = $advModel->AddAdsDefaultCoverImage($ad);
+ $advs[$index]->seo_link = $this->adv_repository->getModel()->getAdvDetailLinkByModel($ad, 'list');
+ $advs[$index] = $this->adv_repository->getModel()->AddAdsDefaultCoverImage($ad);
}
return response()->json($advs);
}
- public function getAdvsByProfile(AdvRepositoryInterface $advRepository, Request $request)
- {
- $my_advs = new AdvModel();
- $type = $request->type;
- if ($type == 'pending') {
- $page_title = trans('visiosoft.module.advs::field.pending_adv.name');
- $my_advs = $my_advs->pendingAdvsByUser();
- } else if ($type == 'favs') {
- //Get Favorites Advs
- $isActiveFavs = new AdvModel();
- $isActiveFavs = $isActiveFavs->is_enabled('favs');
-
- if ($isActiveFavs) {
-
- $page_title = trans('visiosoft.module.advs::field.favs_adv.name');
- $favs = new FavsController();
- $favs = $favs->getFavsByProfile();
-
- $fav_ids = array();
- foreach ($favs as $fav) {
- $fav_ids[] = $fav['adv_name_id'];//fav advs id List
- }
- $my_advs = $my_advs->favsAdvsByUser($fav_ids);
- }
- } else {
- $page_title = trans('visiosoft.module.advs::field.my_adv.name');
- $my_advs = $my_advs->myAdvsByUser();
- }
- $my_advs = $my_advs->orderByDesc('id');
- $my_advs = $advRepository->addAttributes($my_advs->get());
- $files = array();
- foreach ($my_advs as $my_adv) {
- $files[] = $my_adv->files;
- }
- return response()->json(['success' => true, 'content' => $my_advs, 'files' => $files, 'title' => $page_title]);
- }
-
- public function authCheck()
- {
- if (auth()->check()) {
- return auth()->user();
- }
-
- return "false";
- }
-
- public function isActive($slug)
- {
- $query = new AdvModel();
-
- return $query->is_enabled($slug);
- }
-
- public function isActiveJson($slug)
- {
- $isActive = $this->isActive($slug);
- return response()->json(array('isActive' => $isActive));
- }
-
- public function checkParentCat($id)
- {
- $option = new CategoryModel();
- return $option->getParentCats($id);
- }
-
- public function checkUser()
- {
- if (Auth::check()) {
- return response()->json([
- 'success' => true,
- ]);
- } else {
- return response()->json([
- 'success' => false,
- ]);
- }
- }
-
- public function advAddCart($id, $quantity = 1)
- {
- $thisModel = new AdvModel();
- $adv = $thisModel->isAdv($id);
- $response = array();
- if ($adv) {
- $cart = $thisModel->addCart($adv, $quantity);
- $response['status'] = "success";
- } else {
- $response['status'] = "error";
- $response['msg'] = trans('visiosoft.module.advs::message.error_added_cart');
- }
- return back();
- }
-
- public function addCart(Request $request)
- {
- 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'] = "guest";
- }
- return $response;
- }
-
- public function stockControl(Request $request, AdvRepositoryInterface $advRepository)
- {
- $quantity = $request->quantity;
- $id = $request->id;
- $type = $request->type;
- $advmodel = new AdvModel();
- $adv = $advmodel->getAdv($id);
-
- $status = $advmodel->stockControl($id, $quantity);
-
- $response = array();
- if ($status == 1) {
- $response['newQuantity'] = $advRepository->getQuantity($quantity, $type, $adv);
-
- } else {
- $response['newQuantity'] = $adv->stock;
- }
-
- $response['newPrice'] = $adv->price * $response['newQuantity'];
-
- $separator = ",";
- $decimals = 2;
- $point = ".";
-
- $response['newPrice'] = number_format($response['newPrice'], $decimals, $point, str_replace(' ', ' ', $separator));
- $symbol = config('streams::currencies.supported.' . strtoupper($adv->currency) . '.symbol');
-
- $response['newPrice'] = $symbol . $response['newPrice'];
- $response['status'] = $status;
- $response['maxQuantity'] = $adv->stock;
- return $response;
- }
-
- public function showPhoneCounter(Request $request, AdvModel $advModel, Dispatcher $events)
- {
- $ad_id = $request->id;
- $ad = $advModel->getAdv($ad_id);
-
- if ($advModel->is_enabled('phoneclickcounter')) {
- $events->dispatch(new showAdPhone($ad));//show ad phone events
- }
- return "success";
- }
-
public function extendAll($isAdmin = null)
{
$adsExtended = $this->adv_repository->extendAds(true, $isAdmin);