diff --git a/.env_demo b/.env_demo index 8d6c6e533..1b50a89cc 100644 --- a/.env_demo +++ b/.env_demo @@ -1,4 +1,10 @@ +DB_CONNECTION=mysql +DB_HOST=localhost +DB_PORT=3307 +DB_DATABASE=oc +DB_USERNAME=root +DB_PASSWORD="" APP_NAME="OpenClassify" FORCE_SSL=0 @@ -13,13 +19,15 @@ DEFAULT_LOCALE="en" ENABLED_LOCALES='a:1:{i:0;s:2:"en";}' MAINTENANCE_MODE=0 MAINTENANCE_AUTH=0 -FROM_ADDRESS="support@demo.openclassify.com" +FROM_ADDRESS="info@openclassify.com" FROM_NAME="OpenClassify" + MAIL_DRIVER="smtp" MAIL_HOST=smtp.mailtrap.io MAIL_PORT=2525 MAIL_USERNAME="029f2d0c9099d9" MAIL_PASSWORD="8252f6d1c2ca42" + HTTP_CACHE=0 HTTP_CACHE_TTL=3600 HTTP_CACHE_ALLOW_BOTS=0 diff --git a/addons/default/visiosoft/advs-module/composer.json b/addons/default/visiosoft/advs-module/composer.json index c33a66956..bb6a02f5d 100644 --- a/addons/default/visiosoft/advs-module/composer.json +++ b/addons/default/visiosoft/advs-module/composer.json @@ -8,12 +8,5 @@ "files": [ "src/Support/_helpers.php" ] - }, - "require": { - "wirelab/language_switcher-plugin": "^1.3", - "visiosoft/addblock-extension": "^1.1", - "ext-zip": "*", - "chumper/zipper": "^1.0", - "sentry/sentry-laravel": "2.3.1" } } diff --git a/addons/default/visiosoft/advs-module/migrations/2020_12_18_134817_visiosoft.module.advs__create_user_status_field.php b/addons/default/visiosoft/advs-module/migrations/2020_12_18_134817_visiosoft.module.advs__create_user_status_field.php deleted file mode 100644 index 690d449c1..000000000 --- a/addons/default/visiosoft/advs-module/migrations/2020_12_18_134817_visiosoft.module.advs__create_user_status_field.php +++ /dev/null @@ -1,26 +0,0 @@ - 'advs', - ]; - - protected $fields = [ - "user_status" => [ - "type" => "anomaly.field_type.relationship", - "config" => [ - "related" => \Visiosoft\AdvsModule\Status\StatusModel::class, - "mode" => "lookup", - ] - ], - ]; - - protected $assignments = [ - 'user_status', - ]; -} diff --git a/addons/default/visiosoft/advs-module/resources/config/settings/settings.php b/addons/default/visiosoft/advs-module/resources/config/settings/settings.php index b3b1734d9..9ae81b704 100644 --- a/addons/default/visiosoft/advs-module/resources/config/settings/settings.php +++ b/addons/default/visiosoft/advs-module/resources/config/settings/settings.php @@ -98,7 +98,7 @@ return [ 'type' => 'anomaly.field_type.checkboxes', 'config' => [ 'options' => function (\Visiosoft\CatsModule\Category\Contract\CategoryRepositoryInterface $categoryRepository) { - return $categoryRepository->mainCats()->pluck('name', 'id')->all(); + return $categoryRepository->getMainCategories()->pluck('name', 'id')->all(); }, ], ], @@ -399,7 +399,7 @@ return [ 'type' => 'anomaly.field_type.checkboxes', 'config' => [ 'options' => function (\Visiosoft\CatsModule\Category\Contract\CategoryRepositoryInterface $categoryRepository) { - return $categoryRepository->mainCats()->pluck('name', 'id')->all(); + return $categoryRepository->getMainCategories()->pluck('name', 'id')->all(); }, ], ], diff --git a/addons/default/visiosoft/advs-module/resources/js/edit_cats.js b/addons/default/visiosoft/advs-module/resources/js/edit_cats.js index be359bc32..590b48333 100644 --- a/addons/default/visiosoft/advs-module/resources/js/edit_cats.js +++ b/addons/default/visiosoft/advs-module/resources/js/edit_cats.js @@ -126,4 +126,4 @@ function scroolToSelect(fields) { $([document.documentElement, document.body]).animate({ scrollTop: $(fields[fields.length - 1]).offset().top + 300 }, 1000); -} +} \ No newline at end of file diff --git a/addons/default/visiosoft/advs-module/resources/views/list/partials/list-filter.twig b/addons/default/visiosoft/advs-module/resources/views/list/partials/list-filter.twig index 4658f388b..8aa9d7415 100644 --- a/addons/default/visiosoft/advs-module/resources/views/list/partials/list-filter.twig +++ b/addons/default/visiosoft/advs-module/resources/views/list/partials/list-filter.twig @@ -24,25 +24,25 @@ {% include 'visiosoft.module.cats::ads-list/partials/cat-filter' %} - {{ addBlock('ads-list/partials/list-filter',{ - 'mainCats':mainCats, - 'subCats':subCats, - 'ranges':ranges, - 'checkboxes':checkboxes, - 'topfields' : topfields, - 'selectDropdown' : selectDropdown, - 'selectRange' : selectRange, - 'selectImage' : selectImage, - 'radio':radio, - 'countries':countries, - 'cities':cities, - 'districts':districts, - 'neighborhoods':neighborhoods, - 'villages':villages, - 'param':param, - 'categoryId':categoryId, - 'cityId':cityId - })|raw }} + {{ addBlock('ads-list/partials/list-filter',{ + 'mainCats':mainCats, + 'subCats':subCats, + 'ranges':ranges, + 'checkboxes':checkboxes, + 'topfields' : topfields, + 'selectDropdown' : selectDropdown, + 'selectRange' : selectRange, + 'selectImage' : selectImage, + 'radio':radio, + 'countries':countries, + 'cities':cities, + 'districts':districts, + 'neighborhoods':neighborhoods, + 'villages':villages, + 'param':param, + 'category':category, + 'cityId':cityId + })|raw }} {% include 'visiosoft.module.advs::list/partials/price-filter' %} diff --git a/addons/default/visiosoft/advs-module/resources/views/list/partials/price-filter.twig b/addons/default/visiosoft/advs-module/resources/views/list/partials/price-filter.twig index ba9294da5..dac50a6d4 100644 --- a/addons/default/visiosoft/advs-module/resources/views/list/partials/price-filter.twig +++ b/addons/default/visiosoft/advs-module/resources/views/list/partials/price-filter.twig @@ -1,14 +1,16 @@ -{% set isHidden = false %} - -{% for cat in cats %} - {% if request().segment(2) == cat.slug %} - {% set isHidden = true %} - {% endif %} -{% endfor %} - -{% if setting_value('visiosoft.module.advs::hide_price_filter') == false and not isHidden%} - {% set hidePriceCats = setting_value('visiosoft.module.advs::hide_price_categories') %} +{% set hidePriceCats = setting_value('visiosoft.module.advs::hide_price_categories') %} +{% if (hidePriceCats != null) %} {% set cats = entries('cats','category').whereIn('id', hidePriceCats).get() %} + {% set isHidden = false %} + + {% for cat in cats %} + {% if request().segment(2) == cat.slug %} + {% set isHidden = true %} + {% endif %} + {% endfor %} +{% endif %} +{% if setting_value('visiosoft.module.advs::hide_price_filter') == false and not isHidden %} + {% set active_currencies = setting_value('visiosoft.module.advs::enabled_currencies') %}
diff --git a/addons/default/visiosoft/advs-module/resources/views/new-ad/edit-cat.twig b/addons/default/visiosoft/advs-module/resources/views/new-ad/edit-cat.twig index 328e9fe23..ae5fa76c3 100644 --- a/addons/default/visiosoft/advs-module/resources/views/new-ad/edit-cat.twig +++ b/addons/default/visiosoft/advs-module/resources/views/new-ad/edit-cat.twig @@ -38,4 +38,4 @@ {{ asset_add("scripts.js", "visiosoft.module.advs::js/edit_cats.js") }} {{ asset_style("visiosoft.module.advs::css/edit_category.css") }} -{% endblock %} +{% endblock %} \ No newline at end of file diff --git a/addons/default/visiosoft/advs-module/resources/views/new-ad/new-create.twig b/addons/default/visiosoft/advs-module/resources/views/new-ad/new-create.twig index dd6532f7f..d203ab172 100644 --- a/addons/default/visiosoft/advs-module/resources/views/new-ad/new-create.twig +++ b/addons/default/visiosoft/advs-module/resources/views/new-ad/new-create.twig @@ -208,7 +208,7 @@
- {% set other_fields = addBlock('new-ad/other-fields',{'custom_fields':custom_fields}) %} + {% set other_fields = addBlock('new-ad/other-fields',{'custom_fields':custom_fields,'id':id}) %} {% if other_fields or (custom_fields and count(custom_fields)) %}
{{ trans('visiosoft.module.advs::field.additional_fields') }} diff --git a/addons/default/visiosoft/advs-module/src/Adv/AdvCriteria.php b/addons/default/visiosoft/advs-module/src/Adv/AdvCriteria.php index 6518e653d..fab2723a8 100644 --- a/addons/default/visiosoft/advs-module/src/Adv/AdvCriteria.php +++ b/addons/default/visiosoft/advs-module/src/Adv/AdvCriteria.php @@ -91,7 +91,7 @@ class AdvCriteria extends EntryCriteria public function countAdsByCategoryId($catId, $level = 1) { - return $this->advRepository->countByCat($catId, $level); + return $this->advRepository->getAdsCountByCategory($catId, $level); } public function getCurrentLocale() diff --git a/addons/default/visiosoft/advs-module/src/Adv/AdvLoader.php b/addons/default/visiosoft/advs-module/src/Adv/AdvLoader.php index 455b8adc2..0d18b2581 100644 --- a/addons/default/visiosoft/advs-module/src/Adv/AdvLoader.php +++ b/addons/default/visiosoft/advs-module/src/Adv/AdvLoader.php @@ -10,7 +10,7 @@ use Visiosoft\AdvsModule\Adv\Contract\AdvInterface; use Anomaly\Streams\Platform\View\ViewTemplate; use Visiosoft\CatsModule\Category\Contract\CategoryInterface; use Visiosoft\LocationModule\City\Contract\CityInterface; -use Visiosoft\LocationModule\Country\Contract\CountryInterface; +use Visiosoft\LocationModule\Country\Contract\CountryRepositoryInterface; class AdvLoader { @@ -21,8 +21,8 @@ class AdvLoader { $this->template = $template; } - public function load(AdvInterface $adv, CategoryInterface $cats, CityInterface $city, CountryInterface $country) { + public function load(AdvInterface $adv, CategoryInterface $cats, CityInterface $city, CountryRepositoryInterface $country) { $this->template->set('adv', $adv); - $this->template->set('country', $country->getCountry($adv->country_id)); + $this->template->set('country', $country->find($adv->country_id)); } } \ No newline at end of file diff --git a/addons/default/visiosoft/advs-module/src/Adv/AdvRepository.php b/addons/default/visiosoft/advs-module/src/Adv/AdvRepository.php index 7466c9224..967f96c48 100644 --- a/addons/default/visiosoft/advs-module/src/Adv/AdvRepository.php +++ b/addons/default/visiosoft/advs-module/src/Adv/AdvRepository.php @@ -10,6 +10,7 @@ use Visiosoft\AdvsModule\Adv\Contract\AdvRepositoryInterface; use Anomaly\Streams\Platform\Entry\EntryRepository; use Visiosoft\AdvsModule\Support\Command\Currency; use Visiosoft\CatsModule\Category\CategoryModel; +use Visiosoft\CatsModule\Category\Contract\CategoryRepositoryInterface; use Visiosoft\LocationModule\City\CityModel; use Visiosoft\LocationModule\Country\CountryModel; use Visiosoft\LocationModule\District\DistrictModel; @@ -31,11 +32,6 @@ class AdvRepository extends EntryRepository implements AdvRepositoryInterface $this->folderRepository = $folderRepository; } - public function findById($id) - { - return $this->model->orderBy('created_at', 'DESC')->where('advs_advs.id', $id)->first(); - } - public function searchAdvs( $type, $param = null, $customParameters = [], $limit = null, $category = null, $city = null, $paginate = true @@ -89,16 +85,11 @@ class AdvRepository extends EntryRepository implements AdvRepositoryInterface } } if ($category) { - $cat = new CategoryModel(); - if ($category) { - if ($category->parent_category_id == null) { - $catLevel = 1; - } else { - $catLevel = $cat->getCatLevel($category->id); - } - $catLevel = "cat" . $catLevel; - $query = $query->where($catLevel, $category->id); - } + $category_repository = app(CategoryRepositoryInterface::class); + + $catLevel = $category_repository->getLevelById($category->id); + $catLevel = "cat" . $catLevel; + $query = $query->where($catLevel, $category->id); } if (!empty($param['user'])) { $query = $query->where('advs_advs.created_by_id', $param['user']); @@ -308,7 +299,7 @@ class AdvRepository extends EntryRepository implements AdvRepositoryInterface $thumbnail = $this->fileRepository->findByNameAndFolder($fileName, $folder); if (!$thumbnail) { // Create thumbnail image - $image = Image::make(file_get_contents($adv->files[0]->url())); + $image = Image::make(file_get_contents($adv->files[0]->make()->url())); $image->resize( null, setting_value('visiosoft.module.advs::thumbnail_height'), @@ -431,7 +422,7 @@ class AdvRepository extends EntryRepository implements AdvRepositoryInterface return $ads; } - public function countByCat($catID, $level = 1) + public function getAdsCountByCategory($catID, $level = 1) { return DB::table('advs_advs') ->whereDate('finish_at', '>=', date("Y-m-d H:i:s")) diff --git a/addons/default/visiosoft/advs-module/src/Adv/AdvResolver.php b/addons/default/visiosoft/advs-module/src/Adv/AdvResolver.php index 25b13ed2f..3e70e0bb5 100644 --- a/addons/default/visiosoft/advs-module/src/Adv/AdvResolver.php +++ b/addons/default/visiosoft/advs-module/src/Adv/AdvResolver.php @@ -16,6 +16,6 @@ class AdvResolver { } public function resolve() { - return $this->adv->findById($this->route->parameter('id')); + return $this->adv->find($this->route->parameter('id')); } } \ No newline at end of file diff --git a/addons/default/visiosoft/advs-module/src/Adv/Command/GetAd.php b/addons/default/visiosoft/advs-module/src/Adv/Command/GetAd.php index 17ec929c5..b415264e9 100644 --- a/addons/default/visiosoft/advs-module/src/Adv/Command/GetAd.php +++ b/addons/default/visiosoft/advs-module/src/Adv/Command/GetAd.php @@ -27,7 +27,7 @@ class GetAd public function handle(AdvRepositoryInterface $groups) { if ($this->id) { - return $groups->findById($this->id); + return $groups->find($this->id); } return null; } diff --git a/addons/default/visiosoft/advs-module/src/Adv/Contract/AdvRepositoryInterface.php b/addons/default/visiosoft/advs-module/src/Adv/Contract/AdvRepositoryInterface.php index 2e5a4ed35..7b71113b6 100644 --- a/addons/default/visiosoft/advs-module/src/Adv/Contract/AdvRepositoryInterface.php +++ b/addons/default/visiosoft/advs-module/src/Adv/Contract/AdvRepositoryInterface.php @@ -4,8 +4,6 @@ use Anomaly\Streams\Platform\Entry\Contract\EntryRepositoryInterface; interface AdvRepositoryInterface extends EntryRepositoryInterface { - public function findById($id); - public function searchAdvs( $type, $param = null, $customParameters = null, $limit = null, $category = null, $city = null, $paginate = true @@ -39,7 +37,7 @@ interface AdvRepositoryInterface extends EntryRepositoryInterface public function getByCat($catID, $level = 1, $limit = 20); - public function countByCat($catID, $level = 1); + public function getAdsCountByCategory($catID, $level = 1); public function getCategoriesWithAdID($id); diff --git a/addons/default/visiosoft/advs-module/src/Adv/Event/ChangedStatusAd.php b/addons/default/visiosoft/advs-module/src/Adv/Event/ChangedStatusAd.php index 5efadc9e4..ffc84c0b2 100644 --- a/addons/default/visiosoft/advs-module/src/Adv/Event/ChangedStatusAd.php +++ b/addons/default/visiosoft/advs-module/src/Adv/Event/ChangedStatusAd.php @@ -1,12 +1,10 @@ ad = $ad; } diff --git a/addons/default/visiosoft/advs-module/src/Adv/Event/DeletedAd.php b/addons/default/visiosoft/advs-module/src/Adv/Event/DeletedAd.php index 2499320e0..3dcbcc78d 100644 --- a/addons/default/visiosoft/advs-module/src/Adv/Event/DeletedAd.php +++ b/addons/default/visiosoft/advs-module/src/Adv/Event/DeletedAd.php @@ -1,17 +1,21 @@ entry = $entry; + $this->ad = $ad; + } + + public function getAdDetail() + { + return $this->ad; } public function getEntry() { - return $this->entry; + return $this->ad; } } diff --git a/addons/default/visiosoft/advs-module/src/Adv/Event/EditAd.php b/addons/default/visiosoft/advs-module/src/Adv/Event/EditAd.php index ed5646b47..dee96cc62 100644 --- a/addons/default/visiosoft/advs-module/src/Adv/Event/EditAd.php +++ b/addons/default/visiosoft/advs-module/src/Adv/Event/EditAd.php @@ -3,15 +3,13 @@ class EditAd { - public function __construct($request, $settings, $adv) + public function __construct($ad) { - $this->request = $request; - $this->settings = $settings; - $this->adv = $adv; + $this->ad = $ad; } - public function getRequest() + public function getAd() { - return $this; + return $this->ad; } } diff --git a/addons/default/visiosoft/advs-module/src/Adv/Event/EditedAd.php b/addons/default/visiosoft/advs-module/src/Adv/Event/EditedAd.php new file mode 100644 index 000000000..f3fb3d6b4 --- /dev/null +++ b/addons/default/visiosoft/advs-module/src/Adv/Event/EditedAd.php @@ -0,0 +1,23 @@ +ad = $ad; + $this->before_editing = $before_editing; + } + + public function getAdDetail() + { + return $this->ad; + } + + public function getBeforeEditingDetail() + { + return $this->before_editing; + } +} diff --git a/addons/default/visiosoft/advs-module/src/Adv/Event/EditedAdCategory.php b/addons/default/visiosoft/advs-module/src/Adv/Event/EditedAdCategory.php new file mode 100644 index 000000000..6015f7b99 --- /dev/null +++ b/addons/default/visiosoft/advs-module/src/Adv/Event/EditedAdCategory.php @@ -0,0 +1,23 @@ +ad = $ad; + $this->before_editing_ad_params = $before_editing_ad_params; + } + + public function getAdDetail() + { + return $this->ad; + } + + public function getBeforeEditingParams() + { + return $this->before_editing_ad_params; + } +} diff --git a/addons/default/visiosoft/advs-module/src/Adv/Event/priceChange.php b/addons/default/visiosoft/advs-module/src/Adv/Event/PriceChange.php similarity index 92% rename from addons/default/visiosoft/advs-module/src/Adv/Event/priceChange.php rename to addons/default/visiosoft/advs-module/src/Adv/Event/PriceChange.php index 26be17cfb..631047e45 100644 --- a/addons/default/visiosoft/advs-module/src/Adv/Event/priceChange.php +++ b/addons/default/visiosoft/advs-module/src/Adv/Event/PriceChange.php @@ -1,7 +1,7 @@ advRepository = $advRepository; + } + + public function handle(DeletedCategory $event) + { + $category = $event->getCategory(); + + $catLevelNum = ($category->parent_category_id) ? count($event->getParents()) : 1; + + $catLevelText = "cat" . $catLevelNum; + + $advs = $this->advRepository->newQuery()->where($catLevelText, $category->id)->get(); + foreach ($advs as $adv) { + $nullableCats = array(); + for ($i = $catLevelNum; $i <= 10; $i++) { + $nullableCats['cat' . $i] = null; + } + $adv->update($nullableCats); + } + } +} \ No newline at end of file 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 64d123424..364106ebe 100644 --- a/addons/default/visiosoft/advs-module/src/Adv/Table/AdvTableBuilder.php +++ b/addons/default/visiosoft/advs-module/src/Adv/Table/AdvTableBuilder.php @@ -27,7 +27,9 @@ class AdvTableBuilder extends TableBuilder protected $buttons = []; protected $actions = [ - 'delete', + 'delete' => [ + 'handler' => \Visiosoft\AdvsModule\Adv\Table\Handler\Delete::class, + ], 'approve' => [ 'handler' => \Visiosoft\AdvsModule\Adv\Table\Handler\Approve::class, 'class' => 'btn btn-success' @@ -49,8 +51,7 @@ class AdvTableBuilder extends TableBuilder protected $options = [ 'order_by' => [ 'id' => 'DESC', - ], - 'table_view' => 'visiosoft.module.advs::admin/table/table' + ] ]; protected $assets = [ diff --git a/addons/default/visiosoft/advs-module/src/Adv/Table/AdvTableColumns.php b/addons/default/visiosoft/advs-module/src/Adv/Table/AdvTableColumns.php index b8364f0fe..d21553fd2 100644 --- a/addons/default/visiosoft/advs-module/src/Adv/Table/AdvTableColumns.php +++ b/addons/default/visiosoft/advs-module/src/Adv/Table/AdvTableColumns.php @@ -3,6 +3,7 @@ use Anomaly\Streams\Platform\Entry\Contract\EntryInterface; use Anomaly\Streams\Platform\Entry\EntryModel; use Visiosoft\CatsModule\Category\CategoryModel; +use Visiosoft\CatsModule\Category\Contract\CategoryRepositoryInterface; class AdvTableColumns { @@ -39,10 +40,11 @@ class AdvTableColumns } return $value; }, - 'category' => function (EntryInterface $entry, CategoryModel $categoryModel) { - $category = $categoryModel->getCat($entry->cat1); - if (!is_null($category)) + 'category' => function (EntryInterface $entry, CategoryRepositoryInterface $categoryRepository) { + $category = $categoryRepository->find($entry->cat1); + if ($category){ return $category->name; + } } ], ], diff --git a/addons/default/visiosoft/advs-module/src/Adv/Table/AdvTableFilters.php b/addons/default/visiosoft/advs-module/src/Adv/Table/AdvTableFilters.php index 3b78437aa..b257d48a6 100644 --- a/addons/default/visiosoft/advs-module/src/Adv/Table/AdvTableFilters.php +++ b/addons/default/visiosoft/advs-module/src/Adv/Table/AdvTableFilters.php @@ -14,7 +14,7 @@ class AdvTableFilters { $cities = $cityRepository->all()->pluck('name', 'id')->all(); - $categories = $categoryRepository->mainCats()->pluck('name', 'id')->all(); + $categories = $categoryRepository->getMainCategories()->pluck('name', 'id')->all(); $builder->setFilters( [ diff --git a/addons/default/visiosoft/advs-module/src/Adv/Table/Handler/Approve.php b/addons/default/visiosoft/advs-module/src/Adv/Table/Handler/Approve.php index c056610c3..199f9ae84 100644 --- a/addons/default/visiosoft/advs-module/src/Adv/Table/Handler/Approve.php +++ b/addons/default/visiosoft/advs-module/src/Adv/Table/Handler/Approve.php @@ -15,14 +15,16 @@ class Approve extends ActionHandler foreach ($selected as $id) { $defaultAdPublishTime = $settingRepository->value('visiosoft.module.advs::default_published_time'); - $ad = $model->newQuery()->find($id); - $ad->update([ - 'status' => 'approved', - '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') - ]); - event(new ChangedStatusAd($ad));//Create Notify + if ($ad = $model->newQuery()->find($id)) { + $ad->update([ + 'status' => 'approved', + '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') + ]); + + event(new ChangedStatusAd($ad));//Create Notify + } } if ($selected) { diff --git a/addons/default/visiosoft/advs-module/src/Adv/Table/Handler/Delete.php b/addons/default/visiosoft/advs-module/src/Adv/Table/Handler/Delete.php new file mode 100644 index 000000000..ec7c5ed9a --- /dev/null +++ b/addons/default/visiosoft/advs-module/src/Adv/Table/Handler/Delete.php @@ -0,0 +1,52 @@ +getTableModel(); + + /* @var EloquentModel $entry */ + foreach ($selected as $id) { + + $entry = $model->find($id); + + $deletable = true; + + if ($entry instanceof EloquentModel) { + $deletable = $entry->isDeletable(); + } + + if ($entry && $deletable && $entry->delete()) { + $builder->fire('row_deleted', compact('builder', 'model', 'entry')); + + event(new DeletedAd($entry)); + + $count++; + } + } + + if ($count) { + $builder->fire('rows_deleted', compact('count', 'builder', 'model')); + } + + if ($selected && $count > 0) { + $this->messages->success(trans('streams::message.delete_success', compact('count'))); + } + + if ($selected && $count === 0) { + $this->messages->warning(trans('streams::message.delete_success', compact('count'))); + } + } +} \ No newline at end of file diff --git a/addons/default/visiosoft/advs-module/src/AdvsModulePlugin.php b/addons/default/visiosoft/advs-module/src/AdvsModulePlugin.php index 484ced357..162329dc5 100644 --- a/addons/default/visiosoft/advs-module/src/AdvsModulePlugin.php +++ b/addons/default/visiosoft/advs-module/src/AdvsModulePlugin.php @@ -43,18 +43,15 @@ class AdvsModulePlugin extends Plugin ), new \Twig_SimpleFunction( 'latestAds', function () { - if (!$latestAds = $this->dispatch(new LatestAds())) { return 0; } - return $latestAds; } ), new \Twig_SimpleFunction( 'appendRequestURL', function ($request, $url, $new_parameters, $removeParams = []) { - return $this->dispatch(new appendRequestURL($request, $url, $new_parameters, $removeParams)); } ), diff --git a/addons/default/visiosoft/advs-module/src/AdvsModuleServiceProvider.php b/addons/default/visiosoft/advs-module/src/AdvsModuleServiceProvider.php index 556294a6e..13d724a0f 100644 --- a/addons/default/visiosoft/advs-module/src/AdvsModuleServiceProvider.php +++ b/addons/default/visiosoft/advs-module/src/AdvsModuleServiceProvider.php @@ -1,5 +1,6 @@ 'Visiosoft\AdvsModule\Http\Controller\Admin\ExcelController@import', ], - - // advsController + // AdvsController 'advs/list' => [ 'as' => 'visiosoft.module.advs::list', - 'uses' => 'Visiosoft\AdvsModule\Http\Controller\advsController@index' + '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', + 'uses' => 'Visiosoft\AdvsModule\Http\Controller\AdvsController@index', ], 'advs/list?cat={id}' => [ 'as' => 'visiosoft.module.advs::list_cat', - 'uses' => 'Visiosoft\AdvsModule\Http\Controller\advsController@index', + 'uses' => 'Visiosoft\AdvsModule\Http\Controller\AdvsController@index', ], 'advs/adv/{id}' => [ 'as' => 'adv_detail_backup', - 'uses' => 'Visiosoft\AdvsModule\Http\Controller\advsController@view' + 'uses' => 'Visiosoft\AdvsModule\Http\Controller\AdvsController@view' ], 'advs/adv/{id}/{seo}' => [ 'as' => 'adv_detail_seo_backup', - 'uses' => 'Visiosoft\AdvsModule\Http\Controller\advsController@view' + 'uses' => 'Visiosoft\AdvsModule\Http\Controller\AdvsController@view' ], 'ad/{id}' => [ 'as' => 'adv_detail', - 'uses' => 'Visiosoft\AdvsModule\Http\Controller\advsController@view' + 'uses' => 'Visiosoft\AdvsModule\Http\Controller\AdvsController@view' ], 'ad/{seo}/{id}' => [ 'as' => 'adv_detail_seo', - 'uses' => 'Visiosoft\AdvsModule\Http\Controller\advsController@view' + 'uses' => 'Visiosoft\AdvsModule\Http\Controller\AdvsController@view' ], 'advs/preview/{id}' => [ 'as' => 'advs_preview', - 'uses' => 'Visiosoft\AdvsModule\Http\Controller\advsController@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@index' + 'uses' => 'Visiosoft\AdvsModule\Http\Controller\AdvsController@index' ], 'c/{category?}/{city?}' => [ 'as' => 'adv_list_seo', - 'uses' => 'Visiosoft\AdvsModule\Http\Controller\advsController@index' + 'uses' => 'Visiosoft\AdvsModule\Http\Controller\AdvsController@index' ], 'advs/create_adv' => [ 'as' => "advs::create_adv", - 'uses' => 'Visiosoft\AdvsModule\Http\Controller\advsController@cats', + 'uses' => 'Visiosoft\AdvsModule\Http\Controller\AdvsController@cats', ], 'advs/create_adv/post_cat' => [ 'as' => 'post_adv', - 'uses' => 'Visiosoft\AdvsModule\Http\Controller\advsController@create', + 'uses' => 'Visiosoft\AdvsModule\Http\Controller\AdvsController@create', ], 'advs/save_adv' => [ 'as' => 'visiosoft.module.advs::post_cat', - 'uses' => 'Visiosoft\AdvsModule\Http\Controller\advsController@store' + 'uses' => 'Visiosoft\AdvsModule\Http\Controller\AdvsController@store' ], 'advs/edit_advs/{id}' => [ 'middleware' => 'auth', 'as' => 'visiosoft.module.advs::edit_adv', - 'uses' => 'Visiosoft\AdvsModule\Http\Controller\advsController@edit', + 'uses' => 'Visiosoft\AdvsModule\Http\Controller\AdvsController@edit', ], 'advs/status/{id},{type}' => [ 'as' => 'visiosoft.module.advs::status', - 'uses' => 'Visiosoft\AdvsModule\Http\Controller\advsController@statusAds' + 'uses' => 'Visiosoft\AdvsModule\Http\Controller\AdvsController@statusAds' ], 'advs/delete/{id}' => [ 'as' => 'advs::delete', - 'uses' => 'Visiosoft\AdvsModule\Http\Controller\advsController@deleteAd', + 'uses' => 'Visiosoft\AdvsModule\Http\Controller\AdvsController@deleteAd', ], 'adv/addCart/{id}' => [ 'as' => 'adv_AddCart', - 'uses' => 'Visiosoft\AdvsModule\Http\Controller\advsController@advAddCart', + 'uses' => 'Visiosoft\AdvsModule\Http\Controller\AdvsController@advAddCart', ], 'ajax/StockControl' => [ 'as' => 'adv_stock_control_ajax', - 'uses' => 'Visiosoft\AdvsModule\Http\Controller\advsController@stockControl', + 'uses' => 'Visiosoft\AdvsModule\Http\Controller\AdvsController@stockControl', ], 'ajax/addCart' => [ 'as' => 'adv_add_cart_ajax', - 'uses' => 'Visiosoft\AdvsModule\Http\Controller\advsController@addCart', + 'uses' => 'Visiosoft\AdvsModule\Http\Controller\AdvsController@addCart', ], 'ajax/countPhone' => [ 'as' => 'adv_count_show_phone', - 'uses' => 'Visiosoft\AdvsModule\Http\Controller\advsController@showPhoneCounter', + 'uses' => 'Visiosoft\AdvsModule\Http\Controller\AdvsController@showPhoneCounter', ], 'view/{type}' => [ 'as' => 'visiosoft.module.advs::view_type', - 'uses' => 'Visiosoft\AdvsModule\Http\Controller\advsController@viewType', + 'uses' => 'Visiosoft\AdvsModule\Http\Controller\AdvsController@viewType', ], 'adv/edit/category/{id}' => [ 'middleware' => 'auth', 'as' => 'adv::edit_category', - 'uses' => 'Visiosoft\AdvsModule\Http\Controller\advsController@editCategoryForAd', + 'uses' => 'Visiosoft\AdvsModule\Http\Controller\AdvsController@editCategoryForAd', ], 'ajax/getcats/{id}' => [ 'as' => 'ajax::getCats', - 'uses' => 'Visiosoft\AdvsModule\Http\Controller\advsController@getCats', + 'uses' => 'Visiosoft\AdvsModule\Http\Controller\AdvsController@getCats', ], 'advs/extendAll/{isAdmin?}' => [ 'as' => 'advs::extendAll', @@ -171,11 +171,11 @@ class AdvsModuleServiceProvider extends AddonServiceProvider 'as' => 'advs::extendSingle', 'uses' => 'Visiosoft\AdvsModule\Http\Controller\AdvsController@extendSingle', ], - 'categories/checkparent/{id}' => 'Visiosoft\AdvsModule\Http\Controller\advsController@checkParentCat', - 'getlocations' => 'Visiosoft\AdvsModule\Http\Controller\advsController@getLocations', - 'class/getcats/{id}' => 'Visiosoft\AdvsModule\Http\Controller\advsController@getCatsForNewAd', - 'mapJson' => 'Visiosoft\AdvsModule\Http\Controller\advsController@mapJson', - 'check_user' => 'Visiosoft\AdvsModule\Http\Controller\advsController@checkUser', + 'categories/checkparent/{id}' => 'Visiosoft\AdvsModule\Http\Controller\AdvsController@checkParentCat', + 'getlocations' => 'Visiosoft\AdvsModule\Http\Controller\AdvsController@getLocations', + 'class/getcats/{id}' => 'Visiosoft\AdvsModule\Http\Controller\AdvsController@getCatsForNewAd', + 'mapJson' => 'Visiosoft\AdvsModule\Http\Controller\AdvsController@mapJson', + 'check_user' => 'Visiosoft\AdvsModule\Http\Controller\AdvsController@checkUser', // AjaxController 'admin/advs/ajax' => [ @@ -271,8 +271,9 @@ class AdvsModuleServiceProvider extends AddonServiceProvider StatusRepositoryInterface::class => StatusRepository::class, ]; - public function boot(AddonCollection $addonCollection, FileModel $fileModel) + public function boot(AddonCollection $addonCollection, FileModel $fileModel,CategoryRepositoryInterface $categoryRepository) { + $settings_url = [ 'general_settings' => [ 'title' => 'visiosoft.module.advs::button.general_settings', diff --git a/addons/default/visiosoft/advs-module/src/Http/Controller/advsController.php b/addons/default/visiosoft/advs-module/src/Http/Controller/AdvsController.php similarity index 74% rename from addons/default/visiosoft/advs-module/src/Http/Controller/advsController.php rename to addons/default/visiosoft/advs-module/src/Http/Controller/AdvsController.php index d7521485d..cf241c783 100644 --- a/addons/default/visiosoft/advs-module/src/Http/Controller/advsController.php +++ b/addons/default/visiosoft/advs-module/src/Http/Controller/AdvsController.php @@ -15,19 +15,20 @@ use Visiosoft\AdvsModule\Adv\AdvModel; use Visiosoft\AdvsModule\Adv\Contract\AdvRepositoryInterface; use Visiosoft\AdvsModule\Adv\Event\ChangedStatusAd; use Visiosoft\AdvsModule\Adv\Event\CreatedAd; -use Visiosoft\AdvsModule\Adv\Event\priceChange; -use Visiosoft\AdvsModule\Adv\Event\showAdPhone; -use Visiosoft\AdvsModule\Adv\Event\viewAd; +use Visiosoft\AdvsModule\Adv\Event\EditAd; +use Visiosoft\AdvsModule\Adv\Event\EditedAd; +use Visiosoft\AdvsModule\Adv\Event\EditedAdCategory; +use Visiosoft\AdvsModule\Adv\Event\PriceChange; +use Visiosoft\AdvsModule\Adv\Event\ShowAdPhone; +use Visiosoft\AdvsModule\Adv\Event\ViewAd; use Visiosoft\AdvsModule\Adv\Form\AdvFormBuilder; use Visiosoft\AdvsModule\Option\Contract\OptionRepositoryInterface; use Visiosoft\AdvsModule\OptionConfiguration\Contract\OptionConfigurationRepositoryInterface; use Visiosoft\AdvsModule\OptionConfiguration\OptionConfigurationModel; use Visiosoft\AdvsModule\Productoption\Contract\ProductoptionRepositoryInterface; use Visiosoft\AdvsModule\ProductoptionsValue\Contract\ProductoptionsValueRepositoryInterface; -use Visiosoft\AlgoliaModule\Search\SearchModel; use Visiosoft\CatsModule\Category\CategoryModel; use Visiosoft\CatsModule\Category\Contract\CategoryRepositoryInterface; -use Visiosoft\CloudinaryModule\Video\VideoModel; use Visiosoft\FavsModule\Http\Controller\FavsController; use Visiosoft\LocationModule\City\CityModel; use Visiosoft\LocationModule\City\CityRepository; @@ -144,15 +145,14 @@ class AdvsController extends PublicController $param = $this->requestHttp->toArray(); - $countries = $this->country_repository->viewAll(); + $countries = $this->country_repository->newQuery()->get(); $isActiveDopings = $this->adv_model->is_enabled('dopings'); // Search by category slug - $categoryId = null; if ($category) { // Slug - $categoryId = $this->category_repository->findBy('slug', $category); - if (!$categoryId) { + $category = $this->category_repository->findBy('slug', $category); + if (!$category) { $this->messages->error(trans('visiosoft.module.advs::message.category_not_exist')); return redirect('/'); } @@ -160,19 +160,19 @@ class AdvsController extends PublicController unset($param['cat']); return redirect(fullLink( $param, - route('adv_list_seo', [$categoryId->slug]) + route('adv_list_seo', [$category->slug]) )); } } elseif (isset($param['cat']) && !empty($param['cat'])) { // Only Param - $categoryId = $this->category_repository->find($param['cat']); - if (!$categoryId) { + $category = $this->category_repository->find($param['cat']); + if (!$category) { $this->messages->error(trans('visiosoft.module.advs::message.category_not_exist')); return redirect('/'); } unset($param['cat']); return redirect(fullLink( $param, - route('adv_list_seo', [$categoryId->slug]) + route('adv_list_seo', [$category->slug]) )); } @@ -191,7 +191,7 @@ class AdvsController extends PublicController unset($param['city']); return redirect(fullLink( $param, - route('adv_list_seo', [$categoryId->slug, $cityId->slug]) + route('adv_list_seo', [$category->slug, $cityId->slug]) )); } elseif ($isOneCity) { // Param and slug $cityId = $this->cityRepository->find($param['city'][0]); @@ -199,13 +199,13 @@ class AdvsController extends PublicController unset($param['city']); return redirect(fullLink( $param, - route('adv_list_seo', [$categoryId->slug, $cityId->slug]) + route('adv_list_seo', [$category->slug, $cityId->slug]) )); } } elseif ($city && $isMultipleCity) { // Slug and multiple param cities return redirect(fullLink( $param, - route('adv_list_seo', [$categoryId->slug]), + route('adv_list_seo', [$category->slug]), array() )); } elseif ($city) { @@ -213,14 +213,14 @@ class AdvsController extends PublicController unset($param['city']); return redirect(fullLink( $param, - route('adv_list_seo', [$categoryId->slug]) + route('adv_list_seo', [$category->slug]) )); } else { // Only slug $cityId = $this->cityRepository->findBy('slug', $city); if (!$cityId) { return redirect(fullLink( $param, - route('adv_list_seo', [$categoryId->slug]) + route('adv_list_seo', [$category->slug]) ), 301); } } @@ -229,7 +229,7 @@ class AdvsController extends PublicController $isActiveCustomFields = $this->adv_model->is_enabled('customfields'); $advs = $this->adv_repository->searchAdvs( - 'list', $param, $customParameters, null, $categoryId, $cityId, false + 'list', $param, $customParameters, null, $category, $cityId, false ); if ($isActiveDopings) { @@ -265,34 +265,40 @@ class AdvsController extends PublicController } } - + $seenList = array(); if ($isActiveCustomFields) { $cfRepository = app('Visiosoft\CustomfieldsModule\CustomField\CustomFieldRepository'); $return_values = $cfRepository->getSeenList($advs); $return_values = $cfRepository - ->getSeenWithCategory($return_values['advs'], $return_values['seenList'], $categoryId); + ->getSeenWithCategory($return_values['advs'], $return_values['seenList'], $category); $advs = $return_values['advs']; $seenList = $return_values['seenList']; } - if ($categoryId) { - $mainCats = $this->category_model->getMains($categoryId->id); - $current_cat = $this->category_model->getCat($categoryId->id); - $mainCats[] = $current_cat; - $subCats = $this->category_repository->getSubCatById($categoryId->id); + if ($category) { + $mainCats = $this->category_repository->getParentCategoryById($category->id); + $subCats = $this->category_repository->getCategoryById($category->id); + + //if there is no subcategory + if (count($subCats) < 1 and count($mainCats) > 1) { + //fetch subcategories of the last category + $subCats = $this->category_repository->getCategoryById($mainCats[1]['id']); + unset($mainCats[0]);//remove last category + } $allCats = false; } else { - $mainCats = $this->category_repository->mainCats(); + $mainCats = $this->category_repository->getMainCategories(); $allCats = true; } - $cFArray = array(); + $cFArray = $checkboxes = $topfields = $selectDropdown = $selectRange = $selectImage = $ranges = $radio = array(); + if ($isActiveCustomFields) { - $returnvalues = app('Visiosoft\CustomfieldsModule\Http\Controller\CustomFieldsController')->index($mainCats, $subCats, $categoryId); + $returnvalues = app('Visiosoft\CustomfieldsModule\Http\Controller\CustomFieldsController')->index($mainCats, $subCats, $category); $checkboxes = $returnvalues['checkboxes']; $topfields = $returnvalues['topfields']; $selectDropdown = $returnvalues['selectDropdown']; @@ -382,11 +388,11 @@ class AdvsController extends PublicController $viewType = $this->requestHttp->cookie('viewType'); - list('catText' => $catText, 'user' => $user) = $this->handleSeo($categoryId, $mainCats, $cityId); + list('catText' => $catText, 'user' => $user) = $this->handleSeo($category, $mainCats, $cityId); $compact = compact('advs', 'countries', 'mainCats', 'subCats', 'checkboxes', 'param', 'user', 'featured_advs', 'viewType', 'topfields', 'selectDropdown', 'selectRange', 'selectImage', 'ranges', - 'seenList', 'radio', 'categoryId', 'cityId', 'allCats', 'catText', 'cFArray'); + 'seenList', 'radio', 'category', 'cityId', 'allCats', 'catText', 'cFArray'); return $this->viewTypeBasedRedirect($viewType, $compact); } @@ -398,10 +404,9 @@ class AdvsController extends PublicController $catText = ''; if ($category) { - $seo_keywords = $this->category_model->getMeta_keywords($category->id); - $seo_description = $this->category_model->getMeta_description($category->id); - - $metaTitle = $this->category_model->getMeta_title($category->id); + $seo_keywords = $category->getMetaKeywords(); + $seo_description = $category->getMetaDescription(); + $metaTitle = $category->name; $metaDesc = $seo_description; $this->template->set('meta_keywords', implode(', ', $seo_keywords)); @@ -512,7 +517,7 @@ class AdvsController extends PublicController for ($i = 1; $i <= 10; $i++) { $cat = "cat" . $i; if ($adv->$cat != null) { - $item = $this->category_repository->getItem($adv->$cat); + $item = $this->category_repository->find($adv->$cat); if (!is_null($item)) { $categories['cat' . $i] = [ 'name' => $item->name, @@ -530,21 +535,14 @@ class AdvsController extends PublicController $features = app('Visiosoft\CustomfieldsModule\Http\Controller\CustomFieldsController')->view($adv); } - //Cloudinary Module $adv->video_url = null; if ($this->adv_model->is_enabled('cloudinary')) { - - $CloudinaryModel = new VideoModel(); - $Cloudinary = $CloudinaryModel->getVideo($id); - - if (count($Cloudinary->get()) > 0) { - $adv->video_url = $Cloudinary->first()->toArray()['url']; - } + $adv->video_url = app('Visiosoft\CloudinaryModule\Http\Controller\VideoController')->getVideoUrl($adv->id); } $options = $this->optionRepository->findAllBy('adv_id', $id); - $this->event->dispatch(new viewAd($adv));//view ad + $this->event->dispatch(new ViewAd($adv));//view ad if (substr($adv->cover_photo, 0, 4) === "http") { $coverPhoto = $adv->cover_photo; @@ -626,7 +624,7 @@ class AdvsController extends PublicController for ($i = 1; $i <= 10; $i++) { $cat = "cat" . $i; if ($adv->$cat != null) { - $item = $this->category_repository->getItem($adv->$cat); + $item = $this->category_repository->find($adv->$cat); if (!is_null($item)) { $categories['cat' . $i] = [ 'name' => $item->name, @@ -640,6 +638,7 @@ class AdvsController extends PublicController $options = $this->optionRepository->findAllBy('adv_id', $id); + $features = array(); if ($this->adv_model->is_enabled('customfields')) { $features = app('Visiosoft\CustomfieldsModule\Http\Controller\CustomFieldsController')->view($adv); } @@ -688,7 +687,7 @@ class AdvsController extends PublicController public function getCats($id) { - return $this->category_repository->getSubCatById($id); + return $this->category_repository->getCategoryById($id); } public function getCatsForNewAd($id) @@ -705,14 +704,14 @@ class AdvsController extends PublicController return $cats; } - public function create(Request $request, AdvFormBuilder $formBuilder, CategoryRepositoryInterface $repository) + public function create(AdvFormBuilder $formBuilder, CategoryRepositoryInterface $repository) { if (!Auth::user()) { redirect('/login?redirect=' . url()->current())->send(); } $isActive = new AdvModel(); - $cats = $request->toArray(); + $cats = $this->request->toArray(); unset($cats['_token']); $end = count($cats); @@ -723,13 +722,13 @@ class AdvsController extends PublicController for ($i = 0; $i < $end; $i++) { $plus1 = $i + 1; - $cat = $repository->getSingleCat($cats['cat' . $plus1]); + $cat = $repository->find($cats['cat' . $plus1]); $cats_d['cat' . $plus1] = $cat->name; } if ($isActive->is_enabled('customfields')) { $custom_fields = app('Visiosoft\CustomfieldsModule\Http\Controller\CustomFieldsController')->create($categories); } - //Cloudinary Module + return $this->view->make('visiosoft.module.advs::new-ad/new-create', compact( 'request', 'formBuilder', 'cats_d', 'custom_fields')); } @@ -737,37 +736,31 @@ class AdvsController extends PublicController public function store ( AdvFormBuilder $form, - MessageBag $messages, - Request $request, - SettingRepositoryInterface $settings, - AdvRepositoryInterface $advRepository, - CategoryRepositoryInterface $categoryRepository, - Dispatcher $events, - AdvModel $advModel, 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 ($this->request->action == "update") { + $error = $form->build($this->request->update_id)->validate()->getFormErrors()->getMessages(); if (!empty($error)) { return $this->redirect->back(); } - /* Update Adv */ - $adv = AdvsAdvsEntryModel::find($request->update_id); + /* Update Adv */ + $before_editing = $this->adv_repository->find($this->request->update_id); + + $adv = $before_editing; + + $is_new_create = ($adv->slug == "") ? true : false; //Set Old Price - $old_price = ($adv->slug == "") ? $request->price : $adv->price; + $old_price = ($adv->slug == "") ? $this->request->price : $adv->price; $adv->old_price = $old_price; $allowPendingAdCreation = false; - if ($advModel->is_enabled('packages') and $adv->slug == "") { - $cat = app('Visiosoft\PackagesModule\Http\Controller\PackageFEController')->AdLimitForNewAd($request); + + if (is_module_installed('visiosoft.module.packages') and $is_new_create) { + $cat = app('Visiosoft\PackagesModule\Http\Controller\PackageFEController')->AdLimitForNewAd($this->request); if (!is_null($cat)) { if (array_key_exists('allowPendingAds', $cat)) { $allowPendingAdCreation = $cat['allowPendingAds']; @@ -778,65 +771,52 @@ class AdvsController extends PublicController } // Create options - $deletedOptions = $request->deleted_options; - $newOptions = $request->new_options; + $deletedOptions = $this->request->deleted_options; + $newOptions = $this->request->new_options; + if (!empty($deletedOptions)) { - $deletedOptions = explode(',', $request->deleted_options); + $deletedOptions = explode(',', $this->request->deleted_options); $this->optionRepository->newQuery() ->whereIn('id', $deletedOptions) - ->where('adv_id', $request->update_id) + ->where('adv_id', $this->request->update_id) ->delete(); } + if (!empty($newOptions)) { - $newOptions = explode(',', $request->new_options); + $newOptions = explode(',', $this->request->new_options); foreach ($newOptions as $option) { $this->optionRepository->create([ 'name' => $option, - 'adv_id' => $request->update_id, + 'adv_id' => $this->request->update_id, ]); } } + //Get Categories Settings $get_categories_status = false; if ($get_categories = setting_value('visiosoft.module.advs::get_categories') and $get_categories = in_array($adv->cat1, $get_categories)) { $get_categories_status = true; } - $adv->is_get_adv = ($request->is_get_adv and $get_categories_status) ? true : false; + $adv->is_get_adv = ($this->request->is_get_adv and $get_categories_status) ? true : false; $adv->save(); - //algolia Search Module - $isActiveAlgolia = $advModel->is_enabled('algolia'); - if ($isActiveAlgolia) { - $algolia = new SearchModel(); - if ($adv->slug == "") { - $algolia->saveAlgolia($adv->toArray(), $settings); - } else { - $algolia->updateAlgolia($request->toArray(), $settings); - } - } - //Cloudinary Module - $isActiveCloudinary = $advModel->is_enabled('cloudinary'); - if ($isActiveCloudinary) { - $CloudinaryModel = new VideoModel(); - $CloudinaryModel->updateRequest($request); - - if ($request->url != "") { - $adv->save(); - } - } - if ($this->adv_model->is_enabled('customfields')) { - app('Visiosoft\CustomfieldsModule\Http\Controller\CustomFieldsController')->store($adv, $request); + //Todo Create Event + if (is_module_installed('visiosoft.module.customfields')) { + app('Visiosoft\CustomfieldsModule\Http\Controller\CustomFieldsController')->store($adv, $this->request); } - // Auto approve + //Todo Create Event + // Auto Approve $autoApprove = true; + if ($allowPendingAdCreation) { $adLogExists = app('Visiosoft\PackagesModule\AdvsLog\Contract\AdvsLogRepositoryInterface') ->findByAdID($adv->id); $autoApprove = $adLogExists ? false : true; } + if (setting_value('visiosoft.module.advs::auto_approve') && $autoApprove) { $defaultAdPublishTime = setting_value('visiosoft.module.advs::default_published_time'); $adv->update([ @@ -846,9 +826,11 @@ class AdvsController extends PublicController ]); } - $form->render($request->update_id); - $adv = $this->adv_repository->find($request->update_id); + $form->render($this->request->update_id); + $adv = $this->adv_repository->find($form->getFormEntryId()); + + //Create Adress if ($this->request->address_id != "") { $address = $address->find($this->request->address_id); $adv->country_id = $address->country_id; @@ -858,57 +840,70 @@ class AdvsController extends PublicController $adv->village = null; $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'] = $this->request->update_id; + + //Price Change Event + $this->event->dispatch(new PriceChange($post)); + + //Cover Image URL + if ($this->request->video_url == "") { + $this->adv_repository->cover_image_update($adv); } + if ($form->hasFormErrors()) { - $cats = $request->toArray(); + $cats = $this->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->find($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/' . $this->request->update_id) + ->with('cats_d', $cats_d) + ->with('request', $this->request); } - event(new CreatedAd($adv)); - $this->adv_model->foreignCurrency($request->currency, $request->price, $request->update_id, $this->settings_repository, false); - return redirect(route('advs_preview', [$request->update_id])); + + if ($is_new_create) { + event(new CreatedAd($adv)); + } else { + $this->adv_model->foreignCurrency($this->request->currency, $this->request->price, $this->request->update_id, $this->settings_repository, false); + event(new EditedAd($before_editing, $adv)); + } + + return redirect(route('advs_preview', [$this->request->update_id])); } /* New Create Adv */ - $request->publish_at = date('Y-m-d H:i:s'); - $all = $request->all(); + $this->request->publish_at = date('Y-m-d H:i:s'); + $all = $this->request->all(); - $packageEnabled = $advModel->is_enabled('packages'); - if ($packageEnabled) { + if (is_module_installed('visiosoft.module.packages')) { unset($all['pack_id']); } - $new = AdvModel::query()->create($all); + $adv = $this->adv_repository->create($all); - if ($packageEnabled + if (is_module_installed('visiosoft.module.packages') && \request()->pack_id && setting_value('visiosoft.module.packages::allow_pending_ad_creation')) { $package = app('Visiosoft\PackagesModule\Package\Contract\PackageRepositoryInterface') ->find(\request()->pack_id); if ($package->price) { app('Visiosoft\PackagesModule\Http\Controller\PackageFEController') - ->packageAddCart(\request()->pack_id, $new->id); + ->packageAddCart(\request()->pack_id, $adv->id); } } - - return redirect('/advs/edit_advs/' . $new->id); + return redirect('/advs/edit_advs/' . $adv->id); } public function edit($id) @@ -932,7 +927,7 @@ class AdvsController extends PublicController for ($i = 1; $i <= 10; $i++) { if ($adv[$cat . $i]) { - $name = $this->category_repository->getSingleCat($adv[$cat . $i]); + $name = $this->category_repository->find($adv[$cat . $i]); if ($name) { $cats_d['cat' . $i] = $name->name; $cats['cat' . $i] = $name->id; @@ -945,20 +940,9 @@ class AdvsController extends PublicController $options = $this->optionRepository->findAllBy('adv_id', $id); - //Cloudinary Module - $Cloudinary = null; - $isActiveCloudinary = $this->adv_model->is_enabled('cloudinary'); - if ($isActiveCloudinary) { - $CloudinaryModel = new VideoModel(); - $Cloudinary = $CloudinaryModel->getVideo($id)->get(); - - if (count($Cloudinary) > 0) { - $Cloudinary = $Cloudinary->first()->toArray(); - } - } - $categories = array_keys($cats); + $custom_fields = array(); if ($this->adv_model->is_enabled('customfields')) { $custom_fields = app('Visiosoft\CustomfieldsModule\Http\Controller\CustomFieldsController') ->edit($adv, $categories, $cats); @@ -974,7 +958,7 @@ class AdvsController extends PublicController return $this->view->make( 'visiosoft.module.advs::new-ad/new-create', - compact('id', 'cats_d', 'cats', 'Cloudinary', 'adv', 'custom_fields', 'options', 'hidePrice') + compact('id', 'cats_d', 'cats', 'adv', 'custom_fields', 'options', 'hidePrice') ); } @@ -1005,14 +989,10 @@ class AdvsController extends PublicController } } - $isActiveAlgolia = $this->adv_model->is_enabled('algolia'); - if ($isActiveAlgolia) { - $algolia = new SearchModel(); - $algolia->updateStatus($id, $type, $settings); - } - $this->adv_model->statusAds($id, $type); + event(new ChangedStatusAd($ad));//Create Notify + if ($type === 'approved') { $message = trans('visiosoft.module.advs::message.approve_status_change'); } elseif ($type === 'sold') { @@ -1029,7 +1009,7 @@ class AdvsController extends PublicController if (!Auth::user()) { redirect('/login?redirect=' . url()->current())->send(); } - $main_cats = $this->category_repository->mainCats(); + $main_cats = $this->category_repository->getMainCategories(); return $this->view->make('visiosoft.module.advs::new-ad/post-cat', compact('main_cats')); } @@ -1037,13 +1017,14 @@ class AdvsController extends PublicController public function editCategoryForAd($id) { $adv = $this->adv_model->userAdv(true)->find($id); + $before_editing_ad_params = $adv->toArray(); if (is_null($adv)) { abort(403); } - if ($this->requestHttp->action == 'update') { - $params = $this->requestHttp->all(); + if ($this->request->action == 'update') { + $params = $this->request->all(); unset($params['action']); for ($i = 1; $i <= 10; $i++) { @@ -1053,6 +1034,7 @@ class AdvsController extends PublicController } $adv->update($params); + $this->event->dispatch(new EditedAdCategory($before_editing_ad_params,$adv)); $this->messages->success(trans('visiosoft.module.advs::message.updated_category_msg')); return redirect('/advs/edit_advs/' . $id); } @@ -1063,55 +1045,9 @@ class AdvsController extends PublicController } - public function login() + public function mapJson(AdvRepositoryInterface $repository) { - 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 mapJson(Request $request, AdvRepositoryInterface $repository) - { - $param = $request->toArray(); + $param = $this->request->toArray(); $customParameters = array(); $advModel = new AdvModel(); @@ -1123,161 +1059,6 @@ class AdvsController extends PublicController 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 isActiveJson($slug) - { - $isActive = $this->isActive($slug); - return response()->json(array('isActive' => $isActive)); - } - - public function isActive($slug) - { - $query = new AdvModel(); - - return $query->is_enabled($slug); - } - - 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) - { - $id = $request->id; - $quantity = $request->quantity; - $name = $request->name; - $thisModel = new AdvModel(); - $adv = $thisModel->isAdv($id); - $response = array(); - if ($adv and $adv->getStatus() == "approved") { - $cart = $thisModel->addCart($adv, $quantity, $name); - $response['status'] = "success"; - $count = $cart->getItems()->count; - $response['count'] = $count; - } else { - $response['status'] = "error"; - $response['msg'] = trans('visiosoft.module.advs::message.error_added_cart'); - } - return $response; - } - - public function stockControl(Request $request, AdvRepositoryInterface $advRepository) - { - $quantity = $request->quantity; - $id = $request->id; - $type = $request->type; - if ($request->dataType === 'ad-configuration') { - $optionConf = new OptionConfigurationModel(); - $adv = $optionConf->newQuery()->find($id); - $status = $adv->stockControl($id, $quantity); - } else { - $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']; - - $response['newPrice'] = app(Currency::class)->format($response['newPrice'], strtoupper($adv->currency)); - $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) { if (\request()->unpublished) { @@ -1297,12 +1078,32 @@ class AdvsController extends PublicController return $this->redirect->back(); } - public function sold($id, Request $request, AdvModel $advModel) + public function sold($id, AdvModel $advModel) { - if ($request->sold == 'sold') { + if ($this->request->sold == 'sold') { $advModel->find($id)->update(['status' => 'sold']); - } elseif ($request->sold = 'not-sold') { + } elseif ($this->request->sold = 'not-sold') { $advModel->find($id)->update(['status' => 'approved']); } } + + 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 and $adv->getStatus() == "approved") { + $cart = $thisModel->addCart($adv, $quantity, $name); + $response['status'] = "success"; + $count = $cart->getItems()->count; + $response['count'] = $count; + } else { + $response['status'] = "error"; + $response['msg'] = trans('visiosoft.module.advs::message.error_added_cart'); + } + return $response; + } } \ No newline at end of file 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 b3ee086e2..b69789f2e 100644 --- a/addons/default/visiosoft/advs-module/src/Http/Controller/AjaxController.php +++ b/addons/default/visiosoft/advs-module/src/Http/Controller/AjaxController.php @@ -50,14 +50,6 @@ class AjaxController extends PublicController return response()->json($datas); } - public function keySearch(Request $request) - { - $datas = []; - $catModel = new CategoryModel(); - $datas['category'] = $catModel->searchKeyword($request->q, $request->selected); - return response()->json($datas); - } - public function viewed(AdvModel $advModel, $id) { $advModel->viewed_Ad($id); diff --git a/addons/default/visiosoft/advs-module/src/OptionConfiguration/Table/OptionConfigurationTableColumns.php b/addons/default/visiosoft/advs-module/src/OptionConfiguration/Table/OptionConfigurationTableColumns.php index 1b8f11618..c822cdab3 100644 --- a/addons/default/visiosoft/advs-module/src/OptionConfiguration/Table/OptionConfigurationTableColumns.php +++ b/addons/default/visiosoft/advs-module/src/OptionConfiguration/Table/OptionConfigurationTableColumns.php @@ -18,7 +18,7 @@ class OptionConfigurationTableColumns 'value' => function (EntryModel $entry, AdvRepositoryInterface $advRepository) { - $adv = $advRepository->findById($entry->parent_adv_id); + $adv = $advRepository->find($entry->parent_adv_id); return "parent_adv_id]) . "'>$adv->name"; } ], diff --git a/addons/default/visiosoft/advs-module/src/OptionHandler/CategoriesOptions.php b/addons/default/visiosoft/advs-module/src/OptionHandler/CategoriesOptions.php index ce3958242..dcf8211d1 100644 --- a/addons/default/visiosoft/advs-module/src/OptionHandler/CategoriesOptions.php +++ b/addons/default/visiosoft/advs-module/src/OptionHandler/CategoriesOptions.php @@ -14,7 +14,7 @@ class CategoriesOptions public function handle(SelectFieldType $fieldType) { - $categories = $this->categoryRepository->mainCats(); + $categories = $this->categoryRepository->getMainCategories(); $options = $categories->pluck('name', 'id')->all(); $fieldType->setOptions($options); } diff --git a/addons/default/visiosoft/base-theme/resources/js/theme/initialize.js b/addons/default/visiosoft/base-theme/resources/js/theme/initialize.js index be480dac4..a52c5dc3e 100644 --- a/addons/default/visiosoft/base-theme/resources/js/theme/initialize.js +++ b/addons/default/visiosoft/base-theme/resources/js/theme/initialize.js @@ -1,5 +1,5 @@ -(function (window, document) { - - // Go! - -})(window, document); +// (function (window, document) { +// +// // Go! +// +// })(window, document); diff --git a/addons/default/visiosoft/base-theme/resources/views/index/default.twig b/addons/default/visiosoft/base-theme/resources/views/index/default.twig index 692f1e7b8..47777283f 100644 --- a/addons/default/visiosoft/base-theme/resources/views/index/default.twig +++ b/addons/default/visiosoft/base-theme/resources/views/index/default.twig @@ -1,10 +1,8 @@
- - -
{% include "visiosoft.theme.base::partials/categories" %}
-
+
+
{{ addBlock('index_top')|raw }}
@@ -19,8 +17,6 @@ {% endif %}
- -
{% for latestAd in latestAds() %}
@@ -28,7 +24,8 @@
-
@@ -70,9 +67,4 @@ {{ addBlock('index')|raw }}
- - - - -
\ No newline at end of file diff --git a/addons/default/visiosoft/base-theme/resources/views/partials/categories-mobile.twig b/addons/default/visiosoft/base-theme/resources/views/partials/categories-mobile.twig index 96f211d5e..bbab72351 100644 --- a/addons/default/visiosoft/base-theme/resources/views/partials/categories-mobile.twig +++ b/addons/default/visiosoft/base-theme/resources/views/partials/categories-mobile.twig @@ -1,15 +1,14 @@ -{% set sub_categories_limit = setting_value('visiosoft.theme.base::home_page_sub_categories_limit') %} -
  • - {% set catIcon = main_category.icon.path != "" ? url('files/' ~ main_category.icon.path) : img('visiosoft.theme.base::images/default-categories-icon.png').url %} - {{ main_category.name }} + {% set categoryIcon = (main_category.icon) ? main_category.icon : img('visiosoft.theme.base::images/default-categories-icon.png').url %} + {{ main_category.name }} {{ main_category.name }}

    - {% set sub_categories = entries('cats','category').where('parent_category_id', main_category.id).where('deleted_at', null).orderBy('sort_order').get() %} - {% for sub_category in sub_categories|slice(0,sub_categories_limit) %} - {{ sub_category.name }}, + {% for subcats in cats.subcats %} + {% if main_category.id == subcats.id %} + {{ subcats.c2_name }}, + {% endif %} {% endfor %}

    diff --git a/addons/default/visiosoft/base-theme/resources/views/partials/categories-web.twig b/addons/default/visiosoft/base-theme/resources/views/partials/categories-web.twig index 9dd2ccf83..8bbda877b 100644 --- a/addons/default/visiosoft/base-theme/resources/views/partials/categories-web.twig +++ b/addons/default/visiosoft/base-theme/resources/views/partials/categories-web.twig @@ -1,48 +1,40 @@ -{% set sub_categories_limit = setting_value('visiosoft.theme.base::home_page_sub_categories_limit') %} -{% set showAdsCount = setting_value('visiosoft.module.advs::show_ads_count') %}
    • - {% set catIcon = main_category.icon.path != "" ? url('files/' ~ main_category.icon.path) : img('visiosoft.theme.base::images/default-categories-icon.png').url %} - {{ main_category.name }} + {% set categoryIcon = (main_category.icon) ? main_category.icon : img('visiosoft.theme.base::images/default-categories-icon.png').url %} + + {{ main_category.name }} {{ main_category.name }} {% if showAdsCount %} - {% set catAdsCount = entries('advs', 'advs').countAdsByCategoryId(main_category.id) %} - ({{ catAdsCount }}) + ({{ main_category.count }}) {% endif %}
        - {% set sub_categories = entries('cats','category').where('parent_category_id', main_category.id).where('deleted_at', null).orderBy('sort_order').get() %} - {% set subCatLoop = [ - { - 'start': 0, - 'end': sub_categories_limit, - 'class': '', - }, - { - 'start': sub_categories_limit, - 'end': count(sub_categories), - 'class': 'hidden hidden-category', - } - ] %} - {% for subLoop in subCatLoop %} - {% for sub_category in sub_categories|slice(subLoop.start, subLoop.end) %} -
      • - {{ sub_category.name }} + {% set subCatCount = 0 %} + {% for subcats in cats.subcats %} + {% if main_category.id == subcats.id %} + {% set subCatCount = subCatCount + 1 %} + + {% set hideclass = "" %} + {% if subCatCount > sub_categories_limit %} + {% set hideclass = "hidden hidden-category" %} + {% endif %} + +
      • + {{ subcats.c2_name }} {% if showAdsCount %} - {% set catLevel = getParentsCount(sub_category.id) + 1 %} - {% set catAdsCount = entries('advs', 'advs').countAdsByCategoryId(sub_category.id, catLevel) %} - ({{ catAdsCount }}) + ({{ subcats.c2_count }}) {% endif %}
      • - {% endfor %} + {% endif %} {% endfor %} - {% if count(sub_categories) > sub_categories_limit %} + {% if subCatCount > sub_categories_limit %}
      • @@ -53,7 +45,6 @@ {{ trans('visiosoft.theme.base::button.hide_all') }} -
      • {% endif %} diff --git a/addons/default/visiosoft/base-theme/resources/views/partials/categories.twig b/addons/default/visiosoft/base-theme/resources/views/partials/categories.twig index e9641ff22..90dcc67dc 100644 --- a/addons/default/visiosoft/base-theme/resources/views/partials/categories.twig +++ b/addons/default/visiosoft/base-theme/resources/views/partials/categories.twig @@ -1,14 +1,8 @@ -
        +{% set sub_categories_limit = setting_value('visiosoft.theme.base::home_page_sub_categories_limit') %} +{% set showAdsCount = setting_value('visiosoft.module.advs::show_ads_count') %} +
        - {{ addBlock('base/categoriesRow')|raw }} -
        - {% set main_categories = entries('cats','category').where('parent_category_id', null).where('deleted_at', null).orderBy('sort_order').get() %} - {% for main_category in main_categories %} + {% set cats = getCategoriesLevel2() %} + {% for main_category in cats.maincats %} {% include "visiosoft.theme.base::partials/categories-web" %} {% include "visiosoft.theme.base::partials/categories-mobile" %} {% endfor %} diff --git a/addons/default/visiosoft/cats-module/migrations/2019_04_03_071244_visiosoft.module.cats__create_placeholderforsearch_stream.php b/addons/default/visiosoft/cats-module/migrations/2019_04_03_071244_visiosoft.module.cats__create_placeholderforsearch_stream.php deleted file mode 100644 index 4b1911fba..000000000 --- a/addons/default/visiosoft/cats-module/migrations/2019_04_03_071244_visiosoft.module.cats__create_placeholderforsearch_stream.php +++ /dev/null @@ -1,35 +0,0 @@ - 'placeholderforsearch', - 'title_column' => 'name', - 'translatable' => true, - 'versionable' => false, - 'trashable' => false, - 'searchable' => false, - 'sortable' => false, - ]; - - /** - * The stream assignments. - * - * @var array - */ - protected $assignments = [ - 'name' => [ - 'translatable' => true, - 'required' => true, - ], - ]; - -} diff --git a/addons/default/visiosoft/cats-module/migrations/2021_01_03_170033_visiosoft.module.cats__adcountLevel.php b/addons/default/visiosoft/cats-module/migrations/2021_01_03_170033_visiosoft.module.cats__adcountLevel.php new file mode 100644 index 000000000..af46da48b --- /dev/null +++ b/addons/default/visiosoft/cats-module/migrations/2021_01_03_170033_visiosoft.module.cats__adcountLevel.php @@ -0,0 +1,19 @@ +integer('level'); + $table->datetime('level_at'); + $table->integer('count'); + $table->datetime('count_at'); + }); + } +} diff --git a/addons/default/visiosoft/cats-module/migrations/2021_01_22_131418_visiosoft.module.cats__change_icon_field_type.php b/addons/default/visiosoft/cats-module/migrations/2021_01_22_131418_visiosoft.module.cats__change_icon_field_type.php new file mode 100644 index 000000000..b90f638d1 --- /dev/null +++ b/addons/default/visiosoft/cats-module/migrations/2021_01_22_131418_visiosoft.module.cats__change_icon_field_type.php @@ -0,0 +1,18 @@ +fields()->findBySlugAndNamespace('icon', 'cats')) { + return; + } + + $field->setAttribute('type', 'visiosoft.field_type.input_file'); + $field->setAttribute('config', []); + $this->fields()->save($field); + } +} diff --git a/addons/default/visiosoft/cats-module/migrations/2021_03_31_104729_visiosoft.module.cats__add_index_table.php b/addons/default/visiosoft/cats-module/migrations/2021_03_31_104729_visiosoft.module.cats__add_index_table.php index 6ecf73dd2..15c60917a 100644 --- a/addons/default/visiosoft/cats-module/migrations/2021_03_31_104729_visiosoft.module.cats__add_index_table.php +++ b/addons/default/visiosoft/cats-module/migrations/2021_03_31_104729_visiosoft.module.cats__add_index_table.php @@ -6,14 +6,14 @@ use Anomaly\Streams\Platform\Database\Migration\Migration; class VisiosoftModuleCatsAddIndexTable extends Migration { - public function up() - { - Schema::table('cats_category', function (Blueprint $table) { - $table->index('deleted_at'); - $table->index('slug'); - $table->index('parent_category_id'); - $table->index('icon_id'); - $table->index('sort_order'); - }); - } +// public function up() +// { +// Schema::table('cats_category', function (Blueprint $table) { +// $table->index('deleted_at'); +// $table->index('slug'); +// $table->index('parent_category_id'); +// $table->index('icon_id'); +// $table->index('sort_order'); +// }); +// } } diff --git a/addons/default/visiosoft/cats-module/resources/config/permissions.php b/addons/default/visiosoft/cats-module/resources/config/permissions.php index f75806fb1..64a793f2c 100644 --- a/addons/default/visiosoft/cats-module/resources/config/permissions.php +++ b/addons/default/visiosoft/cats-module/resources/config/permissions.php @@ -4,11 +4,6 @@ return [ 'category' => [ 'read', 'write', - 'delete', - ], - 'placeholderforsearch' => [ - 'read', - 'write', - 'delete', - ], + 'delete' + ] ]; diff --git a/addons/default/visiosoft/cats-module/resources/lang/en/view.php b/addons/default/visiosoft/cats-module/resources/lang/en/view.php index cebdced2c..d6cd63086 100644 --- a/addons/default/visiosoft/cats-module/resources/lang/en/view.php +++ b/addons/default/visiosoft/cats-module/resources/lang/en/view.php @@ -2,4 +2,6 @@ return [ 'clean_subcategories' => 'Clean Subcategories', + 'ad_count_calculate' => 'Ad Count Calculate', + 'cat_level_calculate' => 'Category Level Calculate', ]; diff --git a/addons/default/visiosoft/cats-module/resources/views/ads-list/partials/cat-filter.twig b/addons/default/visiosoft/cats-module/resources/views/ads-list/partials/cat-filter.twig index 6813c3b3d..88b2d9ad7 100644 --- a/addons/default/visiosoft/cats-module/resources/views/ads-list/partials/cat-filter.twig +++ b/addons/default/visiosoft/cats-module/resources/views/ads-list/partials/cat-filter.twig @@ -5,11 +5,8 @@
      • {% if (not categoryId) or (loop.first and categoryId) %} - {% if maincat.icon %} - {{ maincat.name }} - {% else %} - {{ img('visiosoft.module.advs::images/listing/sample-cat-icon.svg').data|raw }} - {% endif %} + {% set categoryIcon = (maincat.icon.value) ? maincat.icon.value : img('visiosoft.module.advs::images/listing/sample-cat-icon.svg').url %} + {{ main_category.name }} {% endif %}
        diff --git a/addons/default/visiosoft/cats-module/resources/views/ads-list/partials/list-filter.twig b/addons/default/visiosoft/cats-module/resources/views/ads-list/partials/list-filter.twig new file mode 100644 index 000000000..e69de29bb diff --git a/addons/default/visiosoft/cats-module/resources/views/table/table.twig b/addons/default/visiosoft/cats-module/resources/views/table/table.twig index 5fc3bacf8..4b1f42729 100644 --- a/addons/default/visiosoft/cats-module/resources/views/table/table.twig +++ b/addons/default/visiosoft/cats-module/resources/views/table/table.twig @@ -1,6 +1,6 @@ {{ asset_add("scripts.js", "streams::js/table/table.js") }} -{% if not actions.empty() %} +{% if not actions.isEmpty() %} {{ asset_add("scripts.js", "streams::js/table/actions.js") }} {% endif %} @@ -9,70 +9,71 @@ {% endif %}
        - {{ view("streams::table/partials/filters", {'table': table}) }} -
        -
        - {{ view("streams::table/partials/views", {'table': table}) }} - {{ view(table.options.heading ?: "streams::table/partials/heading", {'table': table}) }} -
        -
        -
        - {% if not table.rows.empty() %} - {% block card %} - {{ form_open({ 'url': url_full() }) }} -
        - + {% if app.request.get('cat') != null %} + +
        + {% set parent = category_detail(app.request.get('cat')) %} + {% if parent.parent_category is null %} + {% set parent_url = url('admin/cats') %} + {% else %} + {% set parent_url = url('admin/cats?cat='~parent.parent_category_id) %} + {% endif %} + + {{ trans('module::field.go_to_parent') }} + +
        + {% endif %} + + + {% if not table.rows.isEmpty() %} + {% block card %} +
        + + {{ form_open({ 'url': table.options.url ?: url_full() }) }} +
        +
        + {{ table.options.sortable ? 'data-sortable' }} + {{ html_attributes(table.options.attributes) }}> - {{ view("streams::table/partials/header", {'table': table}) }} + {{ view("streams::table/partials/header", {'table': table}) }} - {% block body %} - {{ view("streams::table/partials/body", {'table': table}) }} - {% endblock %} + {% block body %} + {{ view("streams::table/partials/body", {'table': table}) }} + {% endblock %} - {{ view("streams::table/partials/footer", {'table': table}) }} + {{ view("streams::table/partials/footer", {'table': table}) }} -
        -
        - {{ form_close() }} - {% endblock %} - {% else %} + +
        + {{ form_close() }} - {% block no_results %} -
        -
        - {{ trans(table.options.get('no_results_message', 'streams::message.no_results')) }} -
        -
        - {% endblock %} +
        + {% endblock %} + {% else %} - {% endif %} -
        -
        + {% block no_results %} +
        +
        + {{ trans(table.options.get('no_results_message', 'streams::message.no_results')) }} +
        +
        + {% endblock %} + + {% endif %}
        diff --git a/addons/default/visiosoft/cats-module/src/Category/CategoryCollection.php b/addons/default/visiosoft/cats-module/src/Category/CategoryCollection.php index 8e3ced75b..2dcaf9f18 100644 --- a/addons/default/visiosoft/cats-module/src/Category/CategoryCollection.php +++ b/addons/default/visiosoft/cats-module/src/Category/CategoryCollection.php @@ -1,16 +1,14 @@ filter( - function ($category) { - return (is_null($category->parent_category_id)); - } - ); + $category_repository = app(CategoryRepositoryInterface::class); + return $category_repository->getMainCategories(); } } diff --git a/addons/default/visiosoft/cats-module/src/Category/CategoryCriteria.php b/addons/default/visiosoft/cats-module/src/Category/CategoryCriteria.php index 66c1390d1..b29907903 100644 --- a/addons/default/visiosoft/cats-module/src/Category/CategoryCriteria.php +++ b/addons/default/visiosoft/cats-module/src/Category/CategoryCriteria.php @@ -19,14 +19,7 @@ class CategoryCriteria extends EntryCriteria $this->categoryRepository = $categoryRepository; } - public function getMainCats() { - $mainCats = $this->categoryRepository->mainCats(); - - foreach ($mainCats as $cat) { - $subCount = $this->categoryRepository->newQuery()->where('parent_category_id', $cat->id)->count(); - $cat->hasChild = !!$subCount; - } - - return $mainCats; + public function getMainCategories() { + return $this->categoryRepository->getMainCategories(); } } diff --git a/addons/default/visiosoft/cats-module/src/Category/CategoryModel.php b/addons/default/visiosoft/cats-module/src/Category/CategoryModel.php index e9fcd5163..3710ce233 100644 --- a/addons/default/visiosoft/cats-module/src/Category/CategoryModel.php +++ b/addons/default/visiosoft/cats-module/src/Category/CategoryModel.php @@ -1,175 +1,44 @@ where('cats_category.id', $id) - ->whereRaw('deleted_at IS NULL') - ->first(); + return $this->seo_keyword; } - public function getParentCats($id, $type = null, $noMainCat = true) + public function getMetaDescription() { - $cat = $this->getCat($id); - $catNames = array(); - $cat_ids = array(); - $catNames[] = $cat->name; - $cat_ids[] = $cat->id; - $subCat = $cat->parent_category_id; - if ($subCat != null) { - for ($i = 0; $i < 10; $i++) { - $parCat = $this->getCat($subCat); - if (isset($parCat)) { - if ($parCat->parent_category_id == "") { - if ($type == "add_main") - $catNames[] = $parCat->name; - if ($noMainCat) { - break; - } - } - $catNames[] = $parCat->name; - $cat_ids[] = $parCat->id; - $subCat = $parCat->parent_category_id; - } - } - } - if ($type == 'category_ids') { - return CategoryModel::query() - ->whereIn('cats_category.id', $cat_ids) - ->whereRaw('deleted_at IS NULL') - ->orderBy('cats_category.id', 'asc') - ->get(); - } - if ($type == "parent_id") { - $cat_ids = array_reverse($cat_ids); - return $cat_ids[0]; - } - return $catNames; + return $this->seo_description; } - public function getCatLevel($id) + public function getParent() { - //count parent and itself - return count($this->getParentCats($id)) + 1; - } - - public function getParentsCount($id) - { - $parentCats = array(); - $currentId = $id; - do { - $cat = $this->getCat($currentId); - $catParent = $cat->parent_category_id; - if ($catParent) { - $currentId = $catParent; - $parentCats[] = $catParent; - } - } while ($catParent); - return count($parentCats); - } - - public function getSubCategories($id, $get = null) - { - $sub_categories = $this->where('parent_category_id', $id)->get(); - if ($get == 'id') { - $list_categories_id = array(); - foreach ($sub_categories as $item_category) { - $list_categories_id[] = $item_category->id; - } - return $list_categories_id; - } - return $sub_categories; - } - - public function getAllSubCategories($id) - { - $sub = $this->getSubCategories($id, 'id'); - for ($i = 0; $i <= count($sub) - 1; $i++) { - $sub = array_merge($sub, $this->getSubCategories($sub[$i], 'id')); - } - return $sub; - } - - public function deleteSubCategories($id) - { - $subCategories = $this->getAllSubCategories($id); - if (count($subCategories)) { - $this->newQuery()->whereIn('id', $subCategories)->delete(); - } - - return true; - } - - public function searchKeyword($keyword, $selected = null) - { - $data = []; - $cats = DB::table('cats_category'); - if ($selected != null) { - if (strpos($selected, "-") !== false) { - $selected = explode('-', $selected); - $cats = $cats->whereNotIn('cats_category.id', $selected); - } else { - $cats = $cats->where('cats_category.id', '!=', $selected); - } - } - $cats = $cats->where('name', 'like', $keyword . '%') - ->whereRaw('deleted_at IS NULL'); - - $cats = $cats->leftJoin('cats_category_translations', function ($join) { - $join->on('cats_category.id', '=', 'cats_category_translations.entry_id'); - $join->whereIn('cats_category_translations.locale', [config('app.locale'), setting_value('streams::default_locale'), 'en']);//active lang - }); - $cats = $cats->select('cats_category.*', 'cats_category_translations.name as name'); - $cats = $cats->orderBy('id', 'DESC') - ->groupBy(['cats_category.id']) - ->get(); - foreach ($cats as $cat) { - $link = ''; - $parents = $this->getParentCats($cat->id, null, false); - krsort($parents); - foreach ($parents as $key => $parent) { - if ($key == 0) { - $link .= $parent . ''; - } else { - $link .= $parent . ' > '; - } - } - $data[] = array( - 'id' => $cat->id, - 'name' => $cat->name, - 'parents' => $link, - 'slug' => $cat->slug - ); - } - return $data; - } - - public function getMainCategory() - { - return $this->where('parent_category_id', NULL)->get(); - } - - public function getMeta_keywords($cat_id) - { - return $this->find($cat_id)->seo_keyword; - } - - public function getMeta_description($cat_id) - { - return $this->find($cat_id)->seo_description; - } - - public function getMeta_title($cat_id) - { - return $this->find($cat_id)->name; + return $this->parent_category; } +// public function getMains($id) +// { +// $id = $id ?: $this->id; +// +// $categories = array(); +// $z = 1; +// for ($i = 1; $i <= $z; $i++) { +// if ($main = $this->newQuery()->where('id', $id)->first()->select('id', 'name', 'slug', '')) { +// $categories[] = $main; +// if ($main->parent_category_id != null) { +// $id = $main->parent_category_id; +// $z++; +// } +// } +// } +// $categories = array_reverse($categories); +// unset($categories[count($categories) - 1]); +// return $categories; +// } public function getMains($id = null) { @@ -191,8 +60,8 @@ class CategoryModel extends CatsCategoryEntryModel implements CategoryInterface return $categories; } - public function getParent() + public function setCategoryIconUrl($url) { - return $this->parent_category; + $this->update(['icon' => $url]); } } diff --git a/addons/default/visiosoft/cats-module/src/Category/CategoryPresenter.php b/addons/default/visiosoft/cats-module/src/Category/CategoryPresenter.php index 3d1791434..37ab0d61e 100644 --- a/addons/default/visiosoft/cats-module/src/Category/CategoryPresenter.php +++ b/addons/default/visiosoft/cats-module/src/Category/CategoryPresenter.php @@ -1,30 +1,19 @@ find($id); return $category->name; } - public function getname($id) + public function getParentCategoryById($id) { - $cat = CatsCategoryEntryModel::query()->find($id); - return $cat->name; - } - - public function getMains($id) - { - $category_model = new CategoryModel(); - return $category_model->getMains($id); + $category_repository = app(CategoryRepositoryInterface::class); + return $category_repository->getParentCategoryById($id); } } diff --git a/addons/default/visiosoft/cats-module/src/Category/CategoryRepository.php b/addons/default/visiosoft/cats-module/src/Category/CategoryRepository.php index 06c66381b..597e08e6c 100644 --- a/addons/default/visiosoft/cats-module/src/Category/CategoryRepository.php +++ b/addons/default/visiosoft/cats-module/src/Category/CategoryRepository.php @@ -1,52 +1,28 @@ model = $model; $this->advRepository = $advRepository; } - public function findById($id) + public function getMainCategories() { - return $this->model->orderBy('created_at', 'DESC')->where('cats_category.id', $id)->first(); - } - - public function mainCats() - { - return $this->model->where('parent_category_id', null)->orderBy('sort_order')->get(); - } - - public function getItem($cat) - { - return $this->model->where('cats_category.id', $cat)->first(); - } - - public function getCatById($id) - { - return $this->model->where('cats_category.id', $id)->where('deleted_at', null)->orderBy('sort_order')->get(); + return $this->newQuery() + ->where('parent_category_id', null) + ->orderBy('sort_order') + ->get(); } public function getSubCatById($id) @@ -63,92 +39,142 @@ class CategoryRepository extends EntryRepository implements CategoryRepositoryIn return $cats; } - public function getSingleCat($id) + public function getCategoriesLevel2() { - return CatsCategoryEntryModel::query()->where('cats_category.id', $id)->first(); + $dBName = 'default_cats_category'; + $dBNamet = $dBName . '_translations'; + + $catsDB = DB::table((DB::raw($dBName . ' c1'))) + ->select( + DB::raw('c1.id'), + DB::raw('c1.slug'), + DB::raw('c1.icon'), + DB::raw('c1.count'), + DB::raw('c1.parent_category_id'), + DB::raw('t1.name'), + + DB::raw('c2.id as c2_id'), + DB::raw('c2.slug as c2_slug'), + DB::raw('c2.count as c2_count'), + DB::raw('c2.parent_category_id as c2_parent_category_id'), + DB::raw('t2.name as c2_name') + ) + ->leftJoin((DB::raw($dBName . ' c2')), DB::raw('c2.parent_category_id'), '=', DB::raw('c1.id')) + ->leftJoin((DB::raw($dBNamet . ' t1')), DB::raw('c1.id'), '=', DB::raw('t1.entry_id')) + ->leftJoin((DB::raw($dBNamet . ' t2')), DB::raw('c2.id'), '=', DB::raw('t2.entry_id')) + ->where(DB::raw('t1.locale'), Request()->session()->get('_locale', setting_value('streams::default_locale'))) + ->where(DB::raw('t2.locale'), Request()->session()->get('_locale', setting_value('streams::default_locale'))) + ->where(DB::raw("c1.deleted_at"), NULL) + ->where(DB::raw("c2.deleted_at"), NULL) + ->whereNull(DB::raw("c1.parent_category_id")) + ->orderBy(DB::raw("c1.sort_order")) + ->orderBy(DB::raw("c2.sort_order")) + ->get(); + $cats = collect([]); + $cats->subcats = $catsDB; + $cats->maincats = $catsDB->unique('id'); + return $cats; + } + + public function getCategoryById($id) + { + return $this->newQuery() + ->where('parent_category_id', $id) + ->where('deleted_at', null) + ->orderBy('sort_order')->get(); } public function findBySlug($slug) { - return $this->model->orderBy('created_at', 'DESC')->where('slug', $slug)->first(); + return $this->newQuery() + ->where('slug', $slug) + ->first(); } - public function getCategories() + public function getParentCategoryById($id) { - return $this->model->orderBy('sort_order')->get(); - } - - public function removeCatFromAds($category) - { - $catLevelNum = 1; - if (!is_null($category->parent_category_id)) { - $catLevelNum = $this->model->getCatLevel($category->id); - } - $catLevelText = "cat" . $catLevelNum; - - $advs = $this->advRepository->newQuery()->where($catLevelText, $category->id)->get(); - foreach ($advs as $adv) { - $nullableCats = array(); - for ($i = $catLevelNum; $i <= 10; $i++) { - $nullableCats['cat' . $i] = null; + if ($category = $this->find($id)) { + $parents_count = ($category->parent_category_id) ? 1 : 0; + $parents[] = $category; + for ($i = 0; $i < $parents_count; $i++) { + if ($category = $this->find($category->parent_category_id)) { + $parents[] = $category; + $parents_count++; + } } - $adv->update($nullableCats); + + return $parents; } + return null; } - public function DeleteCategories($id) + public function getLevelById($id) { - if (!is_null($category = $this->find($id))) { - // Remove deleted category from ads - $this->removeCatFromAds($category); - - // Delete the category - $this->model->find($id)->delete(); - - // Delete the subcategories - $this->model->deleteSubCategories($id); - } + $parents = $this->getParentCategoryById($id); + return (is_array($parents)) ? count($parents) : null; } - public function getMainAndSubCats() - { - $dBName = 'cats_category'; - $dBNamet = $dBName . '_translations'; + public function getCategoriesByName($keyword) + { + $cats = DB::table('cats_category'); - $catsDB = DB::table($dBName . ' as c1') - ->select( - 'c1.id', - 'c1.slug', - 'c1.parent_category_id', - 'c1.icon_id', - 't1.name', - 'c2.id as c2_id', - 'c2.slug as c2_slug', - 'c2.parent_category_id as c2_parent_category_id', - 't2.name as c2_name', - 'file.id as file_id' - ) - ->leftJoin($dBName . ' as c2', function ($join) { - $join->on('c2.parent_category_id', '=', 'c1.id') + $cats = $cats->where('name', 'like', $keyword . '%') + ->whereRaw('deleted_at IS NULL'); + + $cats = $cats->leftJoin('cats_category_translations', function ($join) { + $join->on('cats_category.id', '=', 'cats_category_translations.entry_id'); + $join->whereIn('cats_category_translations.locale', [config('app.locale'), setting_value('streams::default_locale'), 'en']);//active lang + }) + ->select('cats_category.*', 'cats_category_translations.name as name') + ->orderBy('id', 'DESC')->groupBy(['cats_category.id'])->get(); + + return $cats; + } + + public function getDeletedCategories() + { + return $this->model->withTrashed()->newQuery()->whereNotNull('deleted_at')->get(); + } + + public function getMainAndSubCats() + { + $dBName = 'cats_category'; + $dBNamet = $dBName . '_translations'; + + $catsDB = DB::table($dBName . ' as c1') + ->select( + 'c1.id', + 'c1.slug', + 'c1.parent_category_id', + 'c1.icon_id', + 't1.name', + 'c2.id as c2_id', + 'c2.slug as c2_slug', + 'c2.parent_category_id as c2_parent_category_id', + 't2.name as c2_name', + 'file.id as file_id' + ) + ->leftJoin($dBName . ' as c2', function ($join) { + $join->on('c2.parent_category_id', '=', 'c1.id') ->whereNull('c2.deleted_at'); }) - ->leftJoin($dBNamet . ' as t1', function ($join) use ($dBNamet) { - $join->on('c1.id', '=', 't1.entry_id') + ->leftJoin($dBNamet . ' as t1', function ($join) use ($dBNamet) { + $join->on('c1.id', '=', 't1.entry_id') ->where('t1.locale', Request()->session()->get('_locale', setting_value('streams::default_locale'))); }) - ->leftJoin($dBNamet . ' as t2', function ($join) use ($dBNamet) { - $join->on('c2.id', '=', 't2.entry_id') + ->leftJoin($dBNamet . ' as t2', function ($join) use ($dBNamet) { + $join->on('c2.id', '=', 't2.entry_id') ->where('t2.locale', Request()->session()->get('_locale', setting_value('streams::default_locale'))); }) - ->leftJoin('files_files as file', 'c1.icon_id', 'file.id') - ->whereNull('c1.deleted_at') - ->whereNull('c1.parent_category_id') - ->orderBy('c1.sort_order') - ->orderBy('c2.sort_order') - ->get(); - $cats = collect([]); - $cats->subcats = $catsDB; - $cats->maincats = $catsDB->unique('id'); - return $cats; - } -} + ->leftJoin('files_files as file', 'c1.icon_id', 'file.id') + ->whereNull('c1.deleted_at') + ->whereNull('c1.parent_category_id') + ->orderBy('c1.sort_order') + ->orderBy('c2.sort_order') + ->get(); + $cats = collect([]); + $cats->subcats = $catsDB; + $cats->maincats = $catsDB->unique('id'); + return $cats; + } +} \ No newline at end of file diff --git a/addons/default/visiosoft/cats-module/src/Category/Command/CalculateAdsCount.php b/addons/default/visiosoft/cats-module/src/Category/Command/CalculateAdsCount.php new file mode 100644 index 000000000..99af5bb11 --- /dev/null +++ b/addons/default/visiosoft/cats-module/src/Category/Command/CalculateAdsCount.php @@ -0,0 +1,53 @@ +category_id = $category_id; + } + + public function handle() + { + $date = new DateTime; + $date->modify('-30 minutes'); + $formatted_date = $date->format('Y-m-d H:i:s'); + + $query = DB::table('cats_category') + ->select('id', 'level'); + + if ($this->category_id and $category = $query->where('id', $this->category_id)->first()) { + $this->calculateCategory($category->id, $category->level); + } else { + $result = $query->where('count_at', '<', $formatted_date) + ->orWhereNull('count_at')->get(); + + foreach ($result as $key => $category) { + $this->calculateCategory($category->id, $category->level); + } + } + } + + public function calculateCategory($category_id, $level) + { + $advRepository = app(AdvRepositoryInterface::class); + if (!empty($level)) { + $count = $advRepository->getAdsCountByCategory($category_id, $level); + DB::table('cats_category')->where('id', $category_id)->update(array( + 'count' => $count, + 'count_at' => now(), + )); + } else { + $this->dispatch(new CalculateCategoryLevel($category_id)); + } + } +} diff --git a/addons/default/visiosoft/cats-module/src/Category/Command/CalculateCategoryLevel.php b/addons/default/visiosoft/cats-module/src/Category/Command/CalculateCategoryLevel.php new file mode 100644 index 000000000..f73c76dc2 --- /dev/null +++ b/addons/default/visiosoft/cats-module/src/Category/Command/CalculateCategoryLevel.php @@ -0,0 +1,56 @@ +category_id = $category_id; + } + + public function handle() + { + if ($this->category_id) { + $this->calculateLevelByCategory($this->category_id); + } else { + $date = new DateTime; + $date->modify('-30 minutes'); + $formatted_date = $date->format('Y-m-d H:i:s'); + + $result = DB::table('cats_category') + ->select('id') + ->where('level_at', '<', $formatted_date) + ->where('level', '=', 0) + ->orWhereNull('level_at') + ->get(); + + foreach ($result as $key => $category) { + $this->calculateLevelByCategory($category->id); + } + } + } + + public function calculateLevelByCategory($category_id) + { + $categoryRepository = app(CategoryRepositoryInterface::class); + + $level = $categoryRepository->getLevelById($category_id); + + if($level) + { + DB::table('cats_category')->where('id', $category_id) + ->update(array( + 'level' => $level, + 'level_at' => now(), + )); + } + } +} diff --git a/addons/default/visiosoft/cats-module/src/Category/Command/getCategoriesLevel2.php b/addons/default/visiosoft/cats-module/src/Category/Command/getCategoriesLevel2.php new file mode 100644 index 000000000..06bf3e951 --- /dev/null +++ b/addons/default/visiosoft/cats-module/src/Category/Command/getCategoriesLevel2.php @@ -0,0 +1,12 @@ +getCategoriesLevel2(); + } +} diff --git a/addons/default/visiosoft/cats-module/src/Category/Contract/CategoryInterface.php b/addons/default/visiosoft/cats-module/src/Category/Contract/CategoryInterface.php index 0e6e89b7b..f18190b63 100644 --- a/addons/default/visiosoft/cats-module/src/Category/Contract/CategoryInterface.php +++ b/addons/default/visiosoft/cats-module/src/Category/Contract/CategoryInterface.php @@ -4,31 +4,13 @@ use Anomaly\Streams\Platform\Entry\Contract\EntryInterface; interface CategoryInterface extends EntryInterface { - public function getCat($id); + public function getMetaKeywords(); - public function getParentCats($id, $type = null); + public function getMetaDescription(); - public function getCatLevel($id); - - public function getParentsCount($id); - - public function getSubCategories($id, $get = null); - - public function getAllSubCategories($id); - - public function deleteSubCategories($id); - - public function searchKeyword($keyword, $selected = null); - - public function getMainCategory(); - - public function getMeta_keywords($cat_id); - - public function getMeta_description($cat_id); - - public function getMeta_title($cat_id); + public function getParent(); public function getMains($id); - public function getParent(); + public function setCategoryIconUrl($url); } diff --git a/addons/default/visiosoft/cats-module/src/Category/Contract/CategoryRepositoryInterface.php b/addons/default/visiosoft/cats-module/src/Category/Contract/CategoryRepositoryInterface.php index 2448359f3..a7852f6fb 100644 --- a/addons/default/visiosoft/cats-module/src/Category/Contract/CategoryRepositoryInterface.php +++ b/addons/default/visiosoft/cats-module/src/Category/Contract/CategoryRepositoryInterface.php @@ -4,23 +4,21 @@ use Anomaly\Streams\Platform\Entry\Contract\EntryRepositoryInterface; interface CategoryRepositoryInterface extends EntryRepositoryInterface { - public function findById($id); + public function getMainCategories(); - public function mainCats(); + public function getCategoriesLevel2(); - public function getItem($cat); - - public function getCatById($id); + public function getCategoryById($id); public function getSubCatById($id); - public function getSingleCat($id); - public function findBySlug($slug); - public function getCategories(); + public function getParentCategoryById($id); - public function DeleteCategories($id); + public function getLevelById($id); + + public function getDeletedCategories(); public function getMainAndSubCats(); } diff --git a/addons/default/visiosoft/cats-module/src/Category/Listener/CalculatedTotalForChangedAdStatus.php b/addons/default/visiosoft/cats-module/src/Category/Listener/CalculatedTotalForChangedAdStatus.php new file mode 100644 index 000000000..010a66517 --- /dev/null +++ b/addons/default/visiosoft/cats-module/src/Category/Listener/CalculatedTotalForChangedAdStatus.php @@ -0,0 +1,24 @@ +categoryRepository = $categoryRepository; + } + + public function handle(ChangedStatusAd $event) + { + $ad_detail = $event->getAdDetail()->toArray(); + + $this->calculateAdAction($ad_detail); + } +} \ No newline at end of file diff --git a/addons/default/visiosoft/cats-module/src/Category/Listener/CalculatedTotalForDeletedAd.php b/addons/default/visiosoft/cats-module/src/Category/Listener/CalculatedTotalForDeletedAd.php new file mode 100644 index 000000000..9fbcbe912 --- /dev/null +++ b/addons/default/visiosoft/cats-module/src/Category/Listener/CalculatedTotalForDeletedAd.php @@ -0,0 +1,24 @@ +categoryRepository = $categoryRepository; + } + + public function handle(DeletedAd $event) + { + $ad_detail = $event->getAdDetail()->toArray(); + + $this->calculateAdAction($ad_detail); + } +} \ No newline at end of file diff --git a/addons/default/visiosoft/cats-module/src/Category/Listener/CalculatedTotalForEditedAdCategory.php b/addons/default/visiosoft/cats-module/src/Category/Listener/CalculatedTotalForEditedAdCategory.php new file mode 100644 index 000000000..09c98d156 --- /dev/null +++ b/addons/default/visiosoft/cats-module/src/Category/Listener/CalculatedTotalForEditedAdCategory.php @@ -0,0 +1,52 @@ +categoryRepository = $categoryRepository; + } + + public function handle(EditedAdCategory $event) + { + $ad_detail = $event->getAdDetail()->toArray(); + $before_editing_ad = $event->getBeforeEditingParams(); + + //Categories New Ad + $category_fields_new_ad = preg_grep('/^cat/i', array_keys($ad_detail)); + $category_fields_new_ad = array_combine($category_fields_new_ad, $category_fields_new_ad); + + foreach ($category_fields_new_ad as $key => $field) { + $category_fields_new_ad[$key] = $ad_detail[$key]; + } + $category_fields_new = array_filter($category_fields_new_ad); + + //Categories Before Editing Ad + $category_fields_old_ad = preg_grep('/^cat/i', array_keys($before_editing_ad)); + $category_fields_old_ad = array_combine($category_fields_old_ad, $category_fields_old_ad); + + foreach ($category_fields_old_ad as $key => $field) { + $category_fields_old_ad[$key] = $before_editing_ad[$key]; + } + $category_fields_old = array_filter($category_fields_old_ad); + + //Update previous category Count + foreach ($category_fields_old as $category_id) { + $this->dispatch(new CalculateAdsCount($category_id)); + } + + //Update New Category Count + foreach ($category_fields_new as $category_id) { + $this->dispatch(new CalculateAdsCount($category_id)); + } + } +} \ No newline at end of file diff --git a/addons/default/visiosoft/cats-module/src/Category/Listener/CalculatedTotalForNewAd.php b/addons/default/visiosoft/cats-module/src/Category/Listener/CalculatedTotalForNewAd.php new file mode 100644 index 000000000..b8def8bfd --- /dev/null +++ b/addons/default/visiosoft/cats-module/src/Category/Listener/CalculatedTotalForNewAd.php @@ -0,0 +1,24 @@ +categoryRepository = $categoryRepository; + } + + public function handle(CreatedAd $event) + { + $ad_detail = $event->getAdDetail()->toArray(); + + $this->calculateAdAction($ad_detail); + } +} \ No newline at end of file diff --git a/addons/default/visiosoft/cats-module/src/Category/Listener/Traits/CalculateAdTrait.php b/addons/default/visiosoft/cats-module/src/Category/Listener/Traits/CalculateAdTrait.php new file mode 100644 index 000000000..5ee803ed5 --- /dev/null +++ b/addons/default/visiosoft/cats-module/src/Category/Listener/Traits/CalculateAdTrait.php @@ -0,0 +1,26 @@ + $field) { + $category_fields[$key] = $ad_detail[$key]; + } + + $category_fields = array_filter($category_fields); + + foreach ($category_fields as $category_id) { + $this->dispatch(new CalculateAdsCount($category_id)); + } + } +} \ No newline at end of file diff --git a/addons/default/visiosoft/cats-module/src/Category/Table/CategoryTableBuilder.php b/addons/default/visiosoft/cats-module/src/Category/Table/CategoryTableBuilder.php index 2a777889e..b1ffb62dd 100644 --- a/addons/default/visiosoft/cats-module/src/Category/Table/CategoryTableBuilder.php +++ b/addons/default/visiosoft/cats-module/src/Category/Table/CategoryTableBuilder.php @@ -17,6 +17,14 @@ class CategoryTableBuilder extends TableBuilder 'clean_subcategories' => [ 'href' => '/admin/cats/clean_subcats', ], + 'adcountcalc' => [ + 'text' => 'visiosoft.module.cats::view.ad_count_calculate', + 'href' => '/admin/cats/adcountcalc', + ], + 'catLevelCalc' => [ + 'text' => 'visiosoft.module.cats::view.cat_level_calculate', + 'href' => '/admin/cats/catlevelcalc', + ], ]; /** @@ -37,32 +45,6 @@ class CategoryTableBuilder extends TableBuilder 'name', ]; - /** - * The table buttons. - * - * @var array|string - */ - protected $buttons = [ - 'edit' => [ - 'href' => '/admin/cats/edit/{entry.id}?parent={entry.parent_category_id}' - ], - 'add_sub_category' => [ - 'icon' => 'fa fa-caret-square-o-down', - 'type' => 'success', - 'href' => '/admin/cats/create?parent={entry.id}' - ], - 'sub_category' => [ - 'icon' => 'fa fa-caret-square-o-down', - 'type' => 'success', - 'href' => '/admin/cats?cat={entry.id}' - ], - 'delete' => [ - 'icon' => 'fa fa-trash', - 'type' => 'danger', - 'href' => '/admin/cats/category/delete/{entry.id}?parent={entry.parent_category_id}' - ] - ]; - /** * The table actions. * @@ -80,7 +62,7 @@ class CategoryTableBuilder extends TableBuilder * @var array */ protected $options = [ - 'table_view' => 'visiosoft.module.cats::table.table' + 'table_view' => 'visiosoft.module.cats::table/table' ]; /** diff --git a/addons/default/visiosoft/cats-module/src/Category/Table/CategoryTableButtons.php b/addons/default/visiosoft/cats-module/src/Category/Table/CategoryTableButtons.php new file mode 100644 index 000000000..4bdc6f1a5 --- /dev/null +++ b/addons/default/visiosoft/cats-module/src/Category/Table/CategoryTableButtons.php @@ -0,0 +1,34 @@ +setButtons([ + 'edit' => [ + 'href' => '/admin/cats/edit/{entry.id}?parent={entry.parent_category_id}' + ], + 'add_sub_category' => [ + 'icon' => 'fa fa-caret-square-o-down', + 'type' => 'success', + 'href' => '/admin/cats/create?parent={entry.id}' + ], + 'sub_category' => [ + 'icon' => 'fa fa-caret-square-o-down', + 'type' => 'success', + 'href' => '/admin/cats?cat={entry.id}' + ], + 'delete' => [ + 'icon' => 'fa fa-trash', + 'type' => 'danger', + 'href' => function(EntryInterface $entry) + { + return route('visiosoft.module.cats::admin.delete_category', ['id' => $entry->getId()])."?parent=".$entry->parent_category_id; + } + ] + ]); + } +} diff --git a/addons/default/visiosoft/cats-module/src/Category/Table/Handler/Delete.php b/addons/default/visiosoft/cats-module/src/Category/Table/Handler/Delete.php index 0dea822bf..6fa1e7343 100644 --- a/addons/default/visiosoft/cats-module/src/Category/Table/Handler/Delete.php +++ b/addons/default/visiosoft/cats-module/src/Category/Table/Handler/Delete.php @@ -1,26 +1,14 @@ DeleteCategories($id); - } + use DeleteCategory; - if ($selected) { - $this->messages->success(trans('visiosoft.module.cats::message.categories_mass_delete_success')); - } - } catch (\Exception $e) { - $this->messages->error($e->getMessage()); - } + public function handle(array $selected) + { + $this->deleteCategories($selected); } } \ No newline at end of file diff --git a/addons/default/visiosoft/cats-module/src/Category/Traits/DeleteCategory.php b/addons/default/visiosoft/cats-module/src/Category/Traits/DeleteCategory.php new file mode 100644 index 000000000..d4b2fd424 --- /dev/null +++ b/addons/default/visiosoft/cats-module/src/Category/Traits/DeleteCategory.php @@ -0,0 +1,42 @@ +deleteCategory($id)) { + $count++; + } + } + + if ($selected && $count > 0) { + $messages->success(trans('streams::message.delete_success', compact('count'))); + } + } + + public function deleteCategory($id) + { + $model = new CategoryModel(); + + $entry = $model->find($id); + + $deletable = true; + + if ($entry instanceof EloquentModel) { + $deletable = $entry->isDeletable(); + } + + if ($entry && $deletable && $entry->delete()) { + return true; + } + return false; + } +} \ No newline at end of file diff --git a/addons/default/visiosoft/cats-module/src/CatsModule.php b/addons/default/visiosoft/cats-module/src/CatsModule.php index 497cfa1e2..c6e5d958b 100644 --- a/addons/default/visiosoft/cats-module/src/CatsModule.php +++ b/addons/default/visiosoft/cats-module/src/CatsModule.php @@ -28,8 +28,8 @@ class CatsModule extends Module 'category' => [ 'buttons' => [ 'new_category', - ], - ], + ] + ] ]; } diff --git a/addons/default/visiosoft/cats-module/src/CatsModulePlugin.php b/addons/default/visiosoft/cats-module/src/CatsModulePlugin.php index 3b13f2a22..b7552ed64 100644 --- a/addons/default/visiosoft/cats-module/src/CatsModulePlugin.php +++ b/addons/default/visiosoft/cats-module/src/CatsModulePlugin.php @@ -1,12 +1,21 @@ categoryRepository = $categoryRepository; + } /** * @return array @@ -37,14 +46,29 @@ class CatsModulePlugin extends Plugin ), new \Twig_SimpleFunction( 'category_parents_name', function ($id) { - $category_model = new CategoryModel(); - return $category_model->getParentCats($id,'add_main'); + return $this->categoryRepository->getParentCategoryById($id); } ), new \Twig_SimpleFunction( 'getParentsCount', function ($id) { - $category_model = new CategoryModel(); - return $category_model->getParentsCount($id); + return count($this->categoryRepository->getParentCategoryById($id)) - 1; + } + ), new \Twig_SimpleFunction( + 'catIcon', + function ($path) { + if ($path == "") { + return $this->dispatch(new MakeImageInstance('visiosoft.theme.base::images/default-categories-icon.png', 'img'))->url(); + } else { + return url('files/' . $path); + } + } + ), new \Twig_SimpleFunction( + 'getCategoriesLevel2', + function () { + if (!$getCategoriesLevel2 = $this->dispatch(new getCategoriesLevel2())) { + return 0; + } + return $getCategoriesLevel2; } ) ]; diff --git a/addons/default/visiosoft/cats-module/src/CatsModuleSeeder.php b/addons/default/visiosoft/cats-module/src/CatsModuleSeeder.php index bd5ebd408..3553251a2 100644 --- a/addons/default/visiosoft/cats-module/src/CatsModuleSeeder.php +++ b/addons/default/visiosoft/cats-module/src/CatsModuleSeeder.php @@ -9,6 +9,6 @@ class CatsModuleSeeder extends Seeder */ public function run() { - // + } } \ No newline at end of file diff --git a/addons/default/visiosoft/cats-module/src/CatsModuleServiceProvider.php b/addons/default/visiosoft/cats-module/src/CatsModuleServiceProvider.php index e083237e0..60915487a 100644 --- a/addons/default/visiosoft/cats-module/src/CatsModuleServiceProvider.php +++ b/addons/default/visiosoft/cats-module/src/CatsModuleServiceProvider.php @@ -1,11 +1,20 @@ 'Visiosoft\CatsModule\Http\Controller\Admin\CategoryController@cleanSubcats', + 'admin/cats/clean_subcats' => 'Visiosoft\CatsModule\Http\Controller\Admin\CategoryController@cleanSubCategories', + 'admin/cats/adcountcalc' => 'Visiosoft\CatsModule\Http\Controller\Admin\CategoryController@adCountCalc', + 'admin/cats/catlevelcalc' => 'Visiosoft\CatsModule\Http\Controller\Admin\CategoryController@catLevelCalc', + 'admin/cats' => 'Visiosoft\CatsModule\Http\Controller\Admin\CategoryController@index', 'admin/cats/create' => 'Visiosoft\CatsModule\Http\Controller\Admin\CategoryController@create', 'admin/cats/edit/{id}' => 'Visiosoft\CatsModule\Http\Controller\Admin\CategoryController@edit', - 'admin/cats/category/delete/{id}' => 'Visiosoft\CatsModule\Http\Controller\Admin\CategoryController@delete', + 'admin/cats/category/delete/{id}' => [ + 'as' => 'visiosoft.module.cats::admin.delete_category', + 'uses' => 'Visiosoft\CatsModule\Http\Controller\Admin\CategoryController@delete', + ], // Sitemap 'sitemap.xml' => 'Visiosoft\CatsModule\Http\Controller\SitemapController@index', @@ -90,9 +105,18 @@ class CatsModuleServiceProvider extends AddonServiceProvider * @type array|null */ protected $listeners = [ - //Visiosoft\CatsModule\Event\ExampleEvent::class => [ - // Visiosoft\CatsModule\Listener\ExampleListener::class, - //], + CreatedAd::class => [ + CalculatedTotalForNewAd::class, + ], + EditedAdCategory::class => [ + CalculatedTotalForEditedAdCategory::class, + ], + ChangedStatusAd::class => [ + CalculatedTotalForChangedAdStatus::class, + ], + DeletedAd::class => [ + CalculatedTotalForDeletedAd::class, + ], ]; /** @@ -190,16 +214,13 @@ class CatsModuleServiceProvider extends AddonServiceProvider 'category' => [ 'buttons' => [ 'new_category' => [ - 'href' => '/admin/cats/create?parent='.$request->cat + 'href' => '/admin/cats/create?parent=' . $request->cat ], ], - ], + ] ]; $this->addon->setSections($sections); } - return parent::getOverrides(); } - - } diff --git a/addons/default/visiosoft/cats-module/src/Http/Controller/Admin/CategoryController.php b/addons/default/visiosoft/cats-module/src/Http/Controller/Admin/CategoryController.php index 50de9afc8..ac9e18ca2 100644 --- a/addons/default/visiosoft/cats-module/src/Http/Controller/Admin/CategoryController.php +++ b/addons/default/visiosoft/cats-module/src/Http/Controller/Admin/CategoryController.php @@ -1,15 +1,22 @@ request->action == "delete") { - $CategoriesModel = new CategoryModel(); - foreach ($this->request->id as $item) { - $CategoriesModel->deleteSubCategories($item); - } - } if (!isset($request->cat) || $request->cat == "") { $categories = CategoryModel::query()->where('parent_category_id', '')->orWhereNull('parent_category_id')->get(); $categories = $categories->where('deleted_at', null); @@ -54,9 +57,11 @@ class CategoryController extends AdminController return $table->render(); } - public function create(CategoryFormBuilder $form, Request $request) + public function create(FileUploader $uploader, FolderRepositoryInterface $folderRepository, MountManager $manager) { if ($this->request->action == "save") { + + $all = $this->request->all(); $id = $all['parent_category']; $parent_id = $all['parent_category']; @@ -111,25 +116,32 @@ class CategoryController extends AdminController } } if (empty($isMultiCat)) { - $this->categoryRepository->create(array_merge($translatableEntries, [ + $category = $this->categoryRepository->create(array_merge($translatableEntries, [ 'slug' => $all['slug'], 'parent_category' => $all['parent_category'] === "" ? null : $all['parent_category'], - 'icon' => $all['icon'], 'seo_keyword' => $all['seo_keyword'], 'seo_description' => $all['seo_description'], ])); + + $this->createIconFile($category->getId()); + + $this->dispatch(new CalculateCategoryLevel($category->getId())); + } else { for ($i = 0; $i < count($isMultiCat[0]); $i++) { foreach ($isMultiCat as $cat) { $translatableEntries = array_merge($translatableEntries, $cat[$i]); } - $this->categoryRepository->create(array_merge($translatableEntries, [ + $category = $this->categoryRepository->create(array_merge($translatableEntries, [ 'slug' => $this->str->slug(reset($translatableEntries)['name'], '_'), 'parent_category' => $all['parent_category'] === "" ? null : $all['parent_category'], - 'icon' => $all['icon'], 'seo_keyword' => $all['seo_keyword'], 'seo_description' => $all['seo_description'], ])); + + $this->createIconFile($category->getId()); + + $this->dispatch(new CalculateCategoryLevel($category->getId())); } }; @@ -171,6 +183,9 @@ class CategoryController extends AdminController if ($form->hasFormErrors()) { return $this->redirect->back(); } + + $this->createIconFile($id); + $parent = $request->parent_category; if ($parent != "") { return $this->redirect->to('/admin/cats?cat=' . $parent); @@ -182,32 +197,80 @@ class CategoryController extends AdminController return $this->view->make('visiosoft.module.cats::cats/admin-cat')->with('id', $id); } - public function delete(CategoryRepositoryInterface $categoryRepository, Request $request, CategoryModel $categoryModel, $id) + public function delete(CategoryRepositoryInterface $categoryRepository, $id) { - $categoryRepository->DeleteCategories($id); - if ($request->parent != "") { - $subCats = $categoryRepository->getSubCatById($request->parent); - if (count($subCats)) { - return redirect('admin/cats?cat=' . $request->parent)->with('success', ['Category and related sub-categories deleted successfully.']); + if ($this->deleteCategory($id)) { + $this->messages->success(trans('streams::message.delete_success', ['count' => 1])); + } + + if (!empty($parent = $this->request->parent)) { + if (count($categoryRepository->getCategoryById($parent))) { + return redirect('admin/cats?cat=' . $parent); } } - return redirect('admin/cats')->with('success', ['Category and related sub-categories deleted successfully.']); + return redirect('admin/cats'); } - public function cleanSubcats() + public function cleanSubCategories() { - $cats = $this->categoryRepository->all(); - $deletedCatsCount = 0; - foreach ($cats as $cat) { - $parentCatId = $cat->parent_category_id; - $parentCat = $this->categoryRepository->find($parentCatId); - if (is_null($parentCat) && !is_null($parentCatId)) { - $this->categoryEntryTranslationsModel->where('entry_id', $cat->id)->delete(); - $this->categoryRepository->DeleteCategories($cat->id); - $deletedCatsCount++; + $sub_c = 1; + for ($i = 0; $i <= $sub_c; $i++) { + $cats = $this->categoryRepository->getDeletedCategories(); + $delete_category_keys = $cats->pluck('id')->all(); + $query_delete = $this->categoryRepository->newQuery()->whereIn('parent_category_id', $delete_category_keys); + if ($query_delete->count()) { + $query_delete->delete(); + $sub_c++; } } - return redirect('admin/cats')->with('success', [$deletedCatsCount . ' categories has been deleted.']); + + return redirect('admin/cats'); + } + + public function adCountCalc() + { + $this->dispatch(new CalculateAdsCount()); + + $this->messages->success(trans('streams::message.edit_success', ['name' => trans('visiosoft.module.cats::addon.title')])); + return redirect('admin/cats'); + } + + public function catLevelCalc() + { + $this->dispatch(new CalculateCategoryLevel()); + + $this->messages->success(trans('streams::message.edit_success', ['name' => trans('visiosoft.module.cats::addon.title')])); + return redirect('admin/cats'); + } + + public function createIconFile($category_id) + { + $folderRepository = app(FolderRepositoryInterface::class); + $manager = app(MountManager::class); + + if ($file = $this->request->file('icon') and $folder = $folderRepository->findBySlug('category_icon') and $category = $this->categoryRepository->find($category_id)) { + + $type = explode('.', $file->getClientOriginalName()); + $type = end($type); + + $file_location = $folder->getDisk()->getSlug() . '://' . $folder->getSlug() . '/' . FileSanitizer::clean($category_id . "." . $type); + + $file_url = '/files/' . $folder->getSlug() . '/' . FileSanitizer::clean($category_id . "." . $type); + + if (Storage::exists($file_location)) { + Storage::delete($file_location); + } + + try { + $manager->put($file_location, file_get_contents($file->getRealPath())); + + $category->setCategoryIconUrl($file_url); + + } catch (\Exception $exception) { + $this->messages->error([$exception->getMessage()]); + } + + } } } diff --git a/addons/default/visiosoft/input_file-field_type/composer.json b/addons/default/visiosoft/input_file-field_type/composer.json new file mode 100644 index 000000000..8609d7e57 --- /dev/null +++ b/addons/default/visiosoft/input_file-field_type/composer.json @@ -0,0 +1,22 @@ +{ + "name": "visiosoft/input_file-field_type", + "type": "streams-addon", + "authors": [ + { + "name": "Visiosoft, LTD.", + "email": "support@visiosoft.com.tr", + "homepage": "https://visiosoft.com.tr/", + "role": "Owner" + }, + { + "name": "Vedat Akdoğan", + "email": "vedat@visiosoft.com.tr", + "role": "Developer" + } + ], + "autoload": { + "psr-4": { + "Visiosoft\\InputFileFieldType\\": "src/" + } + } +} diff --git a/addons/default/visiosoft/input_file-field_type/resources/lang/en/addon.php b/addons/default/visiosoft/input_file-field_type/resources/lang/en/addon.php new file mode 100644 index 000000000..49c9bf5bf --- /dev/null +++ b/addons/default/visiosoft/input_file-field_type/resources/lang/en/addon.php @@ -0,0 +1,7 @@ + 'Input File', + 'name' => 'Input File Field Type', + 'description' => '' +]; diff --git a/addons/default/visiosoft/input_file-field_type/resources/lang/en/input.php b/addons/default/visiosoft/input_file-field_type/resources/lang/en/input.php new file mode 100644 index 000000000..fd50a7dea --- /dev/null +++ b/addons/default/visiosoft/input_file-field_type/resources/lang/en/input.php @@ -0,0 +1,5 @@ + 'Choose File', +]; \ No newline at end of file diff --git a/addons/default/visiosoft/input_file-field_type/resources/views/input.twig b/addons/default/visiosoft/input_file-field_type/resources/views/input.twig new file mode 100644 index 000000000..6af3fae8d --- /dev/null +++ b/addons/default/visiosoft/input_file-field_type/resources/views/input.twig @@ -0,0 +1,5 @@ +
        + +
        + +{#Todo:: Check Accept Input File Field Type#} \ No newline at end of file diff --git a/addons/default/visiosoft/input_file-field_type/src/InputFileFieldType.php b/addons/default/visiosoft/input_file-field_type/src/InputFileFieldType.php new file mode 100644 index 000000000..a528561c5 --- /dev/null +++ b/addons/default/visiosoft/input_file-field_type/src/InputFileFieldType.php @@ -0,0 +1,8 @@ +html = $html; + + parent::__construct($object); + } + +} diff --git a/addons/default/visiosoft/json-field_type/phpunit.xml b/addons/default/visiosoft/json-field_type/phpunit.xml deleted file mode 100644 index 5e8b35e8d..000000000 --- a/addons/default/visiosoft/json-field_type/phpunit.xml +++ /dev/null @@ -1,27 +0,0 @@ - - - - - ./tests - - - - - ./src - - - - - - - - - diff --git a/addons/default/visiosoft/json-field_type/tests/Feature/JsonFieldTypeTest.php b/addons/default/visiosoft/json-field_type/tests/Feature/JsonFieldTypeTest.php deleted file mode 100644 index c0f2070d9..000000000 --- a/addons/default/visiosoft/json-field_type/tests/Feature/JsonFieldTypeTest.php +++ /dev/null @@ -1,10 +0,0 @@ -markTestSkipped('Not implemented.'); - } -} diff --git a/addons/default/visiosoft/location-module/resources/views/ad-detail/details.twig b/addons/default/visiosoft/location-module/resources/views/ad-detail/details.twig index 10053f49d..c408941a0 100644 --- a/addons/default/visiosoft/location-module/resources/views/ad-detail/details.twig +++ b/addons/default/visiosoft/location-module/resources/views/ad-detail/details.twig @@ -1,7 +1,7 @@ {% set adv = params.adv %} -{% if setting_value('visiosoft.module.location::detail_page_location') %} +{% if setting_value('visiosoft.module.location::detail_page_location') and adv.country_name %}
        - {{ adv.city_name }}, {{ adv.country_name }} + {{ (adv.city_name) ? adv.city_name~',' : '' }} {{ adv.country_name }}
        {% endif %} \ No newline at end of file diff --git a/addons/default/visiosoft/location-module/resources/views/ads-list/partials/location-fields.twig b/addons/default/visiosoft/location-module/resources/views/ads-list/partials/location-fields.twig index 0bd32586e..1ce4b6c5e 100644 --- a/addons/default/visiosoft/location-module/resources/views/ads-list/partials/location-fields.twig +++ b/addons/default/visiosoft/location-module/resources/views/ads-list/partials/location-fields.twig @@ -127,5 +127,5 @@ diff --git a/addons/default/visiosoft/location-module/src/City/CityCriteria.php b/addons/default/visiosoft/location-module/src/City/CityCriteria.php index ee57d86bd..356e70070 100644 --- a/addons/default/visiosoft/location-module/src/City/CityCriteria.php +++ b/addons/default/visiosoft/location-module/src/City/CityCriteria.php @@ -1,10 +1,12 @@ query->where('parent_country_id', $city)->get(); + public function getCitiesByCountryId($country_id) { + $city_repository = app(CityRepositoryInterface::class); + return $city_repository->getCitiesByCountryId($country_id); } } diff --git a/addons/default/visiosoft/location-module/src/City/CityModel.php b/addons/default/visiosoft/location-module/src/City/CityModel.php index 5a9283fa9..b6483c28f 100644 --- a/addons/default/visiosoft/location-module/src/City/CityModel.php +++ b/addons/default/visiosoft/location-module/src/City/CityModel.php @@ -2,30 +2,8 @@ use Visiosoft\LocationModule\City\Contract\CityInterface; use Anomaly\Streams\Platform\Model\Location\LocationCitiesEntryModel; -use Visiosoft\LocationModule\District\DistrictModel; class CityModel extends LocationCitiesEntryModel implements CityInterface { - public function getCities($id = null) { - if($id != null) - { - return CityModel::query()->where('location_cities.id', $id)->first(); - } - return CityModel::all(); - } - public function getSubCities($country) { - return $this->query()->where('parent_country_id', $country)->orderBy('order','ASC')->get(); - } - - public function deleteCitiesByCountry($id) { - $districts = new DistrictModel(); - $city = $this->where('parent_country_id',$id); - $city_id = $city->orderBy('id','DESC')->get(); - foreach ($city_id as $item) - { - $districts->deleteDistrictByCity($item->id); - } - return $city->delete(); - } } diff --git a/addons/default/visiosoft/location-module/src/City/CityRepository.php b/addons/default/visiosoft/location-module/src/City/CityRepository.php index 26c711983..9968eae76 100644 --- a/addons/default/visiosoft/location-module/src/City/CityRepository.php +++ b/addons/default/visiosoft/location-module/src/City/CityRepository.php @@ -30,11 +30,6 @@ class CityRepository extends EntryRepository implements CityRepositoryInterface $this->citiesEntryTranslationsModel = $citiesEntryTranslationsModel; } - public function findById($id) - { - return $this->model->orderBy('created_at', 'DESC')->where('location_cities.id', $id)->first(); - } - public function getByEntryIDsAndOrderByTransCol($entryIDs, $orderBy, $direction = 'asc') { return $this->citiesEntryTranslationsModel->newQuery() @@ -48,4 +43,11 @@ class CityRepository extends EntryRepository implements CityRepositoryInterface ->orderBy($orderBy, $direction) ->get(); } + + public function getCitiesByCountryId($country_id) { + return $this->newQuery() + ->where('parent_country_id', $country_id) + ->orderBy('order','ASC') + ->get(); + } } diff --git a/addons/default/visiosoft/location-module/src/City/Contract/CityInterface.php b/addons/default/visiosoft/location-module/src/City/Contract/CityInterface.php index b5891fa0b..ec19657d2 100644 --- a/addons/default/visiosoft/location-module/src/City/Contract/CityInterface.php +++ b/addons/default/visiosoft/location-module/src/City/Contract/CityInterface.php @@ -4,5 +4,5 @@ use Anomaly\Streams\Platform\Entry\Contract\EntryInterface; interface CityInterface extends EntryInterface { - public function getCities(); + } diff --git a/addons/default/visiosoft/location-module/src/City/Contract/CityRepositoryInterface.php b/addons/default/visiosoft/location-module/src/City/Contract/CityRepositoryInterface.php index 2e8993d9d..9952563bd 100644 --- a/addons/default/visiosoft/location-module/src/City/Contract/CityRepositoryInterface.php +++ b/addons/default/visiosoft/location-module/src/City/Contract/CityRepositoryInterface.php @@ -4,7 +4,7 @@ use Anomaly\Streams\Platform\Entry\Contract\EntryRepositoryInterface; interface CityRepositoryInterface extends EntryRepositoryInterface { - public function findById($id); - public function getByEntryIDsAndOrderByTransCol($entryIDs, $orderBy, $direction = 'asc'); + + public function getCitiesByCountryId($country_id); } diff --git a/addons/default/visiosoft/location-module/src/City/Events/DeletedCities.php b/addons/default/visiosoft/location-module/src/City/Events/DeletedCities.php new file mode 100644 index 000000000..062aa7c68 --- /dev/null +++ b/addons/default/visiosoft/location-module/src/City/Events/DeletedCities.php @@ -0,0 +1,17 @@ +cities = $cities; + } + + public function getCities() + { + return $this->cities; + } +} + diff --git a/addons/default/visiosoft/location-module/src/City/Listeners/DeletedCountry.php b/addons/default/visiosoft/location-module/src/City/Listeners/DeletedCountry.php new file mode 100644 index 000000000..e99a20fdd --- /dev/null +++ b/addons/default/visiosoft/location-module/src/City/Listeners/DeletedCountry.php @@ -0,0 +1,28 @@ +cityRepository = $cityRepository; + } + + public function handle(\Visiosoft\LocationModule\Country\Events\DeletedCountry $event) + { + $country = $event->getCountry(); + + $query = $this->cityRepository->newQuery() + ->where('parent_country_id', $country->id); + + if (count($cities = $query->get())) { + $query->delete(); + + event(new DeletedCities($cities)); + } + } +} \ No newline at end of file diff --git a/addons/default/visiosoft/location-module/src/City/Table/CityTableBuilder.php b/addons/default/visiosoft/location-module/src/City/Table/CityTableBuilder.php index a63daae89..5d14f7a64 100644 --- a/addons/default/visiosoft/location-module/src/City/Table/CityTableBuilder.php +++ b/addons/default/visiosoft/location-module/src/City/Table/CityTableBuilder.php @@ -1,6 +1,7 @@ [ + 'handler' => Delete::class, + ], ]; /** diff --git a/addons/default/visiosoft/location-module/src/City/Table/Handler/Delete.php b/addons/default/visiosoft/location-module/src/City/Table/Handler/Delete.php new file mode 100644 index 000000000..ec2612192 --- /dev/null +++ b/addons/default/visiosoft/location-module/src/City/Table/Handler/Delete.php @@ -0,0 +1,24 @@ +newQuery()->whereIn('location_cities.id', $selected); + + if ($count = count($cities = $query->get())) { + $query->delete(); + + event(new DeletedCities($cities)); + } + + if ($selected && $count > 0) { + $this->messages->success(trans('streams::message.delete_success', compact('count'))); + } + } +} \ No newline at end of file diff --git a/addons/default/visiosoft/location-module/src/Country/Contract/CountryInterface.php b/addons/default/visiosoft/location-module/src/Country/Contract/CountryInterface.php index 385275a13..1099e9332 100644 --- a/addons/default/visiosoft/location-module/src/Country/Contract/CountryInterface.php +++ b/addons/default/visiosoft/location-module/src/Country/Contract/CountryInterface.php @@ -4,5 +4,5 @@ use Anomaly\Streams\Platform\Entry\Contract\EntryInterface; interface CountryInterface extends EntryInterface { - public function getCountry($id); + } diff --git a/addons/default/visiosoft/location-module/src/Country/Contract/CountryRepositoryInterface.php b/addons/default/visiosoft/location-module/src/Country/Contract/CountryRepositoryInterface.php index b4659e6ac..769b547c3 100644 --- a/addons/default/visiosoft/location-module/src/Country/Contract/CountryRepositoryInterface.php +++ b/addons/default/visiosoft/location-module/src/Country/Contract/CountryRepositoryInterface.php @@ -4,9 +4,5 @@ use Anomaly\Streams\Platform\Entry\Contract\EntryRepositoryInterface; interface CountryRepositoryInterface extends EntryRepositoryInterface { - public function findById($id); - - public function viewAll(); - public function getByEntryIDsAndOrderByTransCol($entryIDs, $orderBy, $direction = 'asc'); } diff --git a/addons/default/visiosoft/location-module/src/Country/CountryModel.php b/addons/default/visiosoft/location-module/src/Country/CountryModel.php index 7bb3202c5..b2c69af14 100644 --- a/addons/default/visiosoft/location-module/src/Country/CountryModel.php +++ b/addons/default/visiosoft/location-module/src/Country/CountryModel.php @@ -5,8 +5,5 @@ use Anomaly\Streams\Platform\Model\Location\LocationCountriesEntryModel; class CountryModel extends LocationCountriesEntryModel implements CountryInterface { - public function getCountry($id) - { - return CountryModel::query()->where('location_countries.id', $id)->first(); - } + } diff --git a/addons/default/visiosoft/location-module/src/Country/CountryRepository.php b/addons/default/visiosoft/location-module/src/Country/CountryRepository.php index a8a25a6e2..8931d5100 100644 --- a/addons/default/visiosoft/location-module/src/Country/CountryRepository.php +++ b/addons/default/visiosoft/location-module/src/Country/CountryRepository.php @@ -32,14 +32,6 @@ class CountryRepository extends EntryRepository implements CountryRepositoryInte $this->model = $model; $this->countriesEntryTranslationsModel = $countriesEntryTranslationsModel; } - public function findById($id) - { - return $this->model->orderBy('created_at', 'DESC')->where('location_countries.id', $id)->first(); - } - - public function viewAll(){ - return $this->model->get(); - } public function getByEntryIDsAndOrderByTransCol($entryIDs, $orderBy, $direction = 'asc') { diff --git a/addons/default/visiosoft/location-module/src/Country/Events/DeletedCountry.php b/addons/default/visiosoft/location-module/src/Country/Events/DeletedCountry.php new file mode 100644 index 000000000..98f541e89 --- /dev/null +++ b/addons/default/visiosoft/location-module/src/Country/Events/DeletedCountry.php @@ -0,0 +1,17 @@ +country = $country; + } + + public function getCountry() + { + return $this->country; + } +} + diff --git a/addons/default/visiosoft/location-module/src/Country/Table/CountryTableBuilder.php b/addons/default/visiosoft/location-module/src/Country/Table/CountryTableBuilder.php index 733277656..a77e7019e 100644 --- a/addons/default/visiosoft/location-module/src/Country/Table/CountryTableBuilder.php +++ b/addons/default/visiosoft/location-module/src/Country/Table/CountryTableBuilder.php @@ -1,6 +1,7 @@ [ + 'handler' => Delete::class, + ], ]; /** diff --git a/addons/default/visiosoft/location-module/src/Country/Table/Handler/Delete.php b/addons/default/visiosoft/location-module/src/Country/Table/Handler/Delete.php new file mode 100644 index 000000000..2f2471d21 --- /dev/null +++ b/addons/default/visiosoft/location-module/src/Country/Table/Handler/Delete.php @@ -0,0 +1,49 @@ +getTableModel(); + + /* @var EloquentModel $entry */ + foreach ($selected as $id) { + + $entry = $model->find($id); + + $deletable = true; + + if ($entry instanceof EloquentModel) { + $deletable = $entry->isDeletable(); + } + + if ($entry && $deletable && $entry->delete()) { + $builder->fire('row_deleted', compact('builder', 'model', 'entry')); + + event(new DeletedCountry($entry)); + + $count++; + } + } + + if ($count) { + $builder->fire('rows_deleted', compact('count', 'builder', 'model')); + } + + if ($selected && $count > 0) { + $this->messages->success(trans('streams::message.delete_success', compact('count'))); + } + + if ($selected && $count === 0) { + $this->messages->warning(trans('streams::message.delete_success', compact('count'))); + } + } +} \ No newline at end of file diff --git a/addons/default/visiosoft/location-module/src/District/Contract/DistrictRepositoryInterface.php b/addons/default/visiosoft/location-module/src/District/Contract/DistrictRepositoryInterface.php index 465cb1a16..f5a63d7e1 100644 --- a/addons/default/visiosoft/location-module/src/District/Contract/DistrictRepositoryInterface.php +++ b/addons/default/visiosoft/location-module/src/District/Contract/DistrictRepositoryInterface.php @@ -5,4 +5,6 @@ use Anomaly\Streams\Platform\Entry\Contract\EntryRepositoryInterface; interface DistrictRepositoryInterface extends EntryRepositoryInterface { public function getByEntryIDsAndOrderByTransCol($entryIDs, $orderBy, $direction = 'asc'); + + public function getDistrictByCityId($city); } diff --git a/addons/default/visiosoft/location-module/src/District/DistrictModel.php b/addons/default/visiosoft/location-module/src/District/DistrictModel.php index 5f7799002..9e705a3a1 100644 --- a/addons/default/visiosoft/location-module/src/District/DistrictModel.php +++ b/addons/default/visiosoft/location-module/src/District/DistrictModel.php @@ -2,26 +2,8 @@ use Visiosoft\LocationModule\District\Contract\DistrictInterface; use Anomaly\Streams\Platform\Model\Location\LocationDistrictsEntryModel; -use Visiosoft\LocationModule\Neighborhood\NeighborhoodModel; class DistrictModel extends LocationDistrictsEntryModel implements DistrictInterface { - public function getDistricts() { - return DistrictModel::all(); - } - public function getSubDistricts($city) { - return $this->query()->where('parent_city_id', $city)->orderBy('order','ASC')->get(); - } - - public function deleteDistrictByCity($id) { - $neighborhood = new NeighborhoodModel(); - $districts = $this->where('parent_city_id',$id); - $districts_id = $districts->orderBy('id','DESC')->get(); - foreach ($districts_id as $item) - { - $neighborhood->deleteNeighborhoodByDistrict($item->id); - } - return $districts->delete(); - } } diff --git a/addons/default/visiosoft/location-module/src/District/DistrictRepository.php b/addons/default/visiosoft/location-module/src/District/DistrictRepository.php index 3790d78f9..c5fd7e5e6 100644 --- a/addons/default/visiosoft/location-module/src/District/DistrictRepository.php +++ b/addons/default/visiosoft/location-module/src/District/DistrictRepository.php @@ -46,4 +46,11 @@ class DistrictRepository extends EntryRepository implements DistrictRepositoryIn ->orderBy($orderBy, $direction) ->get(); } + + public function getDistrictByCityId($city) { + return $this->newQuery() + ->where('parent_city_id', $city) + ->orderBy('order','ASC') + ->get(); + } } diff --git a/addons/default/visiosoft/location-module/src/District/Events/DeletedDistricts.php b/addons/default/visiosoft/location-module/src/District/Events/DeletedDistricts.php new file mode 100644 index 000000000..131ca72e9 --- /dev/null +++ b/addons/default/visiosoft/location-module/src/District/Events/DeletedDistricts.php @@ -0,0 +1,17 @@ +districts = $districts; + } + + public function getDistricts() + { + return $this->districts; + } +} + diff --git a/addons/default/visiosoft/location-module/src/District/Listeners/DeletedCities.php b/addons/default/visiosoft/location-module/src/District/Listeners/DeletedCities.php new file mode 100644 index 000000000..b55345ebc --- /dev/null +++ b/addons/default/visiosoft/location-module/src/District/Listeners/DeletedCities.php @@ -0,0 +1,30 @@ +districtRepository = $districtRepository; + } + + public function handle(\Visiosoft\LocationModule\City\Events\DeletedCities $event) + { + $cities = $event->getCities(); + + $cities = $cities->pluck('id')->all(); + + $query = $this->districtRepository->newQuery() + ->whereIn('parent_city_id', $cities); + + if (count($districts = $query->get())) { + $query->delete(); + + event(new DeletedDistricts($districts)); + } + } +} \ No newline at end of file diff --git a/addons/default/visiosoft/location-module/src/District/Table/DistrictTableBuilder.php b/addons/default/visiosoft/location-module/src/District/Table/DistrictTableBuilder.php index 4769f45ed..d61fe5312 100644 --- a/addons/default/visiosoft/location-module/src/District/Table/DistrictTableBuilder.php +++ b/addons/default/visiosoft/location-module/src/District/Table/DistrictTableBuilder.php @@ -1,6 +1,7 @@ [ + 'handler' => Delete::class, + ], ]; /** diff --git a/addons/default/visiosoft/location-module/src/District/Table/Handler/Delete.php b/addons/default/visiosoft/location-module/src/District/Table/Handler/Delete.php new file mode 100644 index 000000000..2a22b9cd3 --- /dev/null +++ b/addons/default/visiosoft/location-module/src/District/Table/Handler/Delete.php @@ -0,0 +1,24 @@ +newQuery()->whereIn('location_districts.id', $selected); + + if ($count = count($cities = $query->get())) { + $query->delete(); + + event(new DeletedDistricts($cities)); + } + + if ($selected && $count > 0) { + $this->messages->success(trans('streams::message.delete_success', compact('count'))); + } + } +} \ No newline at end of file diff --git a/addons/default/visiosoft/location-module/src/Http/Controller/Admin/CitiesController.php b/addons/default/visiosoft/location-module/src/Http/Controller/Admin/CitiesController.php index 80d39d931..0e7b30ec2 100644 --- a/addons/default/visiosoft/location-module/src/Http/Controller/Admin/CitiesController.php +++ b/addons/default/visiosoft/location-module/src/Http/Controller/Admin/CitiesController.php @@ -1,29 +1,21 @@ request->action == "delete") { - $disticts = new DistrictModel(); - foreach ($this->request->id as $item) - { - $disticts->deleteDistrictByCity($item); - } - } - $cities = new CityModel(); + $cities = app(CityRepositoryInterface::class); + if(!isset($request->country) || $request->country==""){ return $table->render(); - }else{ - $cities = $cities->getSubCities($request->country); + } else { + $cities = $cities->getCitiesByCountryId($request->country); if (count($cities) == 0) { $this->messages->error('Selected country has no related city.'); return redirect('/admin/location/countries'); diff --git a/addons/default/visiosoft/location-module/src/Http/Controller/Admin/CountriesController.php b/addons/default/visiosoft/location-module/src/Http/Controller/Admin/CountriesController.php index 20a0e810d..ea743be29 100644 --- a/addons/default/visiosoft/location-module/src/Http/Controller/Admin/CountriesController.php +++ b/addons/default/visiosoft/location-module/src/Http/Controller/Admin/CountriesController.php @@ -1,6 +1,5 @@ request->action == "delete") { - $city = new CityModel(); - foreach ($this->request->id as $item) - { - $city->deleteCitiesByCountry($item); - } - } return $table->render(); } diff --git a/addons/default/visiosoft/location-module/src/Http/Controller/Admin/DistrictsController.php b/addons/default/visiosoft/location-module/src/Http/Controller/Admin/DistrictsController.php index dc391e261..f827f1f80 100644 --- a/addons/default/visiosoft/location-module/src/Http/Controller/Admin/DistrictsController.php +++ b/addons/default/visiosoft/location-module/src/Http/Controller/Admin/DistrictsController.php @@ -1,28 +1,20 @@ request->action == "delete") { - $neighborhoods = new NeighborhoodModel(); - foreach ($this->request->id as $item) - { - $neighborhoods->deleteNeighborhoodByDistrict($item); - } - } - $districts = new DistrictModel(); + $districts = app(DistrictRepositoryInterface::class); if(!isset($request->city) || $request->city==""){ return $table->render(); }else{ - $districts = $districts->getSubDistricts($request->city); + $districts = $districts->getDistrictByCityId($request->city); if (count($districts) == 0) { $this->messages->error('Selected city has no related district.'); return redirect('/admin/location/cities'); diff --git a/addons/default/visiosoft/location-module/src/Http/Controller/Admin/NeighborhoodsController.php b/addons/default/visiosoft/location-module/src/Http/Controller/Admin/NeighborhoodsController.php index 6fea82c3c..77bb8bce6 100644 --- a/addons/default/visiosoft/location-module/src/Http/Controller/Admin/NeighborhoodsController.php +++ b/addons/default/visiosoft/location-module/src/Http/Controller/Admin/NeighborhoodsController.php @@ -1,28 +1,20 @@ request->action == "delete") { - $village = new VillageModel(); - foreach ($this->request->id as $item) - { - $village->deleteVillageByNeighborhood($item); - } - } - $neighborhoods = new NeighborhoodModel(); + $neighborhoods = app(NeighborhoodRepositoryInterface::class); if(!isset($request->district) || $request->district==""){ return $table->render(); }else{ - $neighborhoods = $neighborhoods->getSubNeighborhoods($request->district); + $neighborhoods = $neighborhoods->getNeighborhoodsByDistrictId($request->district); if (count($neighborhoods) == 0) { $this->messages->error('Selected district has no related neighborhood.'); return redirect('/admin/location/districts'); diff --git a/addons/default/visiosoft/location-module/src/Http/Controller/Admin/VillageController.php b/addons/default/visiosoft/location-module/src/Http/Controller/Admin/VillageController.php index a09533472..2aa5225f7 100644 --- a/addons/default/visiosoft/location-module/src/Http/Controller/Admin/VillageController.php +++ b/addons/default/visiosoft/location-module/src/Http/Controller/Admin/VillageController.php @@ -1,20 +1,21 @@ neighborhood) || $request->neighborhood==""){ return $table->render(); }else{ - $villages = $villages->getSubVillages($request->neighborhood); + $villages = $villages->getVillagesByNeighborhoodId($request->neighborhood); if (count($villages) == 0) { $this->messages->error('Selected neighborhood has no related village.'); return back(); diff --git a/addons/default/visiosoft/location-module/src/LocationModuleServiceProvider.php b/addons/default/visiosoft/location-module/src/LocationModuleServiceProvider.php index 18343e219..dead6ab68 100644 --- a/addons/default/visiosoft/location-module/src/LocationModuleServiceProvider.php +++ b/addons/default/visiosoft/location-module/src/LocationModuleServiceProvider.php @@ -8,10 +8,14 @@ use Anomaly\Streams\Platform\Model\Location\LocationVillageEntryModel; use Visiosoft\LocationModule\City\CityModel; use Visiosoft\LocationModule\City\CityRepository; use Visiosoft\LocationModule\City\Contract\CityRepositoryInterface; +use Visiosoft\LocationModule\City\Events\DeletedCities; +use Visiosoft\LocationModule\Country\Events\DeletedCountry; use Visiosoft\LocationModule\District\Contract\DistrictRepositoryInterface; use Visiosoft\LocationModule\District\DistrictModel; use Visiosoft\LocationModule\District\DistrictRepository; +use Visiosoft\LocationModule\District\Events\DeletedDistricts; use Visiosoft\LocationModule\Neighborhood\Contract\NeighborhoodRepositoryInterface; +use Visiosoft\LocationModule\Neighborhood\Events\DeletedNeighborhoods; use Visiosoft\LocationModule\Neighborhood\NeighborhoodModel; use Visiosoft\LocationModule\Neighborhood\NeighborhoodRepository; use Visiosoft\LocationModule\Village\Contract\VillageRepositoryInterface; @@ -85,4 +89,19 @@ class LocationModuleServiceProvider extends AddonServiceProvider VillageRepositoryInterface::class => VillageRepository::class, CountryRepositoryInterface::class => CountryRepository::class, ]; + + protected $listeners = [ + DeletedCountry::class => [ + \Visiosoft\LocationModule\City\Listeners\DeletedCountry::class, + ], + DeletedCities::class => [ + \Visiosoft\LocationModule\District\Listeners\DeletedCities::class, + ], + DeletedDistricts::class => [ + \Visiosoft\LocationModule\Neighborhood\Listeners\DeletedDistricts::class, + ], + DeletedNeighborhoods::class => [ + \Visiosoft\LocationModule\Village\Listeners\DeletedNeighborhoods::class + ], + ]; } diff --git a/addons/default/visiosoft/location-module/src/Neighborhood/Contract/NeighborhoodRepositoryInterface.php b/addons/default/visiosoft/location-module/src/Neighborhood/Contract/NeighborhoodRepositoryInterface.php index f1dceaf15..ee82c6b5d 100644 --- a/addons/default/visiosoft/location-module/src/Neighborhood/Contract/NeighborhoodRepositoryInterface.php +++ b/addons/default/visiosoft/location-module/src/Neighborhood/Contract/NeighborhoodRepositoryInterface.php @@ -5,4 +5,6 @@ use Anomaly\Streams\Platform\Entry\Contract\EntryRepositoryInterface; interface NeighborhoodRepositoryInterface extends EntryRepositoryInterface { public function getByEntryIDsAndOrderByTransCol($entryIDs, $orderBy, $direction = 'asc'); + + public function getNeighborhoodsByDistrictId($district); } diff --git a/addons/default/visiosoft/location-module/src/Neighborhood/Events/DeletedNeighborhoods.php b/addons/default/visiosoft/location-module/src/Neighborhood/Events/DeletedNeighborhoods.php new file mode 100644 index 000000000..f1b9f18ab --- /dev/null +++ b/addons/default/visiosoft/location-module/src/Neighborhood/Events/DeletedNeighborhoods.php @@ -0,0 +1,17 @@ +neighborhood = $neighborhood; + } + + public function getNeighborhoods() + { + return $this->neighborhood; + } +} + diff --git a/addons/default/visiosoft/location-module/src/Neighborhood/Listeners/DeletedDistricts.php b/addons/default/visiosoft/location-module/src/Neighborhood/Listeners/DeletedDistricts.php new file mode 100644 index 000000000..dab4bca6b --- /dev/null +++ b/addons/default/visiosoft/location-module/src/Neighborhood/Listeners/DeletedDistricts.php @@ -0,0 +1,31 @@ +neighborhoodRepository = $neighborhoodRepository; + } + + public function handle(\Visiosoft\LocationModule\District\Events\DeletedDistricts $event) + { + $districts = $event->getDistricts(); + + $districts = $districts->pluck('id')->all(); + + $query = $this->neighborhoodRepository->newQuery() + ->whereIn('parent_district_id', $districts); + + if (count($neighborhoods = $query->get())) { + $query->delete(); + + event(new DeletedNeighborhoods($neighborhoods)); + } + } +} \ No newline at end of file diff --git a/addons/default/visiosoft/location-module/src/Neighborhood/NeighborhoodModel.php b/addons/default/visiosoft/location-module/src/Neighborhood/NeighborhoodModel.php index 282d0fcf7..2f70ffb91 100644 --- a/addons/default/visiosoft/location-module/src/Neighborhood/NeighborhoodModel.php +++ b/addons/default/visiosoft/location-module/src/Neighborhood/NeighborhoodModel.php @@ -2,26 +2,8 @@ use Visiosoft\LocationModule\Neighborhood\Contract\NeighborhoodInterface; use Anomaly\Streams\Platform\Model\Location\LocationNeighborhoodsEntryModel; -use Visiosoft\LocationModule\Village\VillageModel; class NeighborhoodModel extends LocationNeighborhoodsEntryModel implements NeighborhoodInterface { - public function getNeighborhoods() { - return NeighborhoodModel::all(); - } - public function getSubNeighborhoods($district) { - return $this->query()->where('parent_district_id', $district)->orderBy('order','ASC')->get(); - } - - public function deleteNeighborhoodByDistrict($id) { - $village = new VillageModel(); - $neighborhood = $this->where('parent_district_id',$id); - $neighborhoods_id = $neighborhood->orderBy('id','DESC')->get(); - foreach ($neighborhoods_id as $item) - { - $village->deleteVillageByNeighborhood($item->id); - } - return $neighborhood->delete(); - } } diff --git a/addons/default/visiosoft/location-module/src/Neighborhood/NeighborhoodRepository.php b/addons/default/visiosoft/location-module/src/Neighborhood/NeighborhoodRepository.php index 75023993e..714038f07 100644 --- a/addons/default/visiosoft/location-module/src/Neighborhood/NeighborhoodRepository.php +++ b/addons/default/visiosoft/location-module/src/Neighborhood/NeighborhoodRepository.php @@ -46,4 +46,12 @@ class NeighborhoodRepository extends EntryRepository implements NeighborhoodRepo ->orderBy($orderBy, $direction) ->get(); } + + public function getNeighborhoodsByDistrictId($district) + { + return $this->newQuery() + ->where('parent_district_id', $district) + ->orderBy('order', 'ASC') + ->get(); + } } diff --git a/addons/default/visiosoft/location-module/src/Neighborhood/Table/Handler/Delete.php b/addons/default/visiosoft/location-module/src/Neighborhood/Table/Handler/Delete.php new file mode 100644 index 000000000..da47f1e88 --- /dev/null +++ b/addons/default/visiosoft/location-module/src/Neighborhood/Table/Handler/Delete.php @@ -0,0 +1,24 @@ +newQuery()->whereIn('location_neighborhoods.id', $selected); + + if ($count = count($cities = $query->get())) { + $query->delete(); + + event(new DeletedNeighborhoods($cities)); + } + + if ($selected && $count > 0) { + $this->messages->success(trans('streams::message.delete_success', compact('count'))); + } + } +} \ No newline at end of file diff --git a/addons/default/visiosoft/location-module/src/Neighborhood/Table/NeighborhoodTableBuilder.php b/addons/default/visiosoft/location-module/src/Neighborhood/Table/NeighborhoodTableBuilder.php index 729f125ac..7dd43d1c5 100644 --- a/addons/default/visiosoft/location-module/src/Neighborhood/Table/NeighborhoodTableBuilder.php +++ b/addons/default/visiosoft/location-module/src/Neighborhood/Table/NeighborhoodTableBuilder.php @@ -1,6 +1,7 @@ [ + 'handler' => Delete::class, + ], ]; /** diff --git a/addons/default/visiosoft/location-module/src/Village/Contract/VillageRepositoryInterface.php b/addons/default/visiosoft/location-module/src/Village/Contract/VillageRepositoryInterface.php index 65f259fdf..d331e84de 100644 --- a/addons/default/visiosoft/location-module/src/Village/Contract/VillageRepositoryInterface.php +++ b/addons/default/visiosoft/location-module/src/Village/Contract/VillageRepositoryInterface.php @@ -5,4 +5,6 @@ use Anomaly\Streams\Platform\Entry\Contract\EntryRepositoryInterface; interface VillageRepositoryInterface extends EntryRepositoryInterface { public function getByEntryIDsAndOrderByTransCol($entryIDs, $orderBy, $direction = 'asc'); + + public function getVillagesByNeighborhoodId($neighborhood); } diff --git a/addons/default/visiosoft/location-module/src/Village/Listeners/DeletedNeighborhoods.php b/addons/default/visiosoft/location-module/src/Village/Listeners/DeletedNeighborhoods.php new file mode 100644 index 000000000..d5806d11b --- /dev/null +++ b/addons/default/visiosoft/location-module/src/Village/Listeners/DeletedNeighborhoods.php @@ -0,0 +1,27 @@ +villageRepository = $villageRepository; + } + + public function handle(\Visiosoft\LocationModule\Neighborhood\Events\DeletedNeighborhoods $event) + { + $neighborhoods = $event->getNeighborhoods(); + + $neighborhoods = $neighborhoods->pluck('id')->all(); + + $query = $this->villageRepository->newQuery() + ->whereIn('parent_neighborhood_id', $neighborhoods); + + if (count($villages = $query->get())) { + $query->delete(); + } + } +} \ No newline at end of file diff --git a/addons/default/visiosoft/location-module/src/Village/VillageModel.php b/addons/default/visiosoft/location-module/src/Village/VillageModel.php index 1df42043f..bcd1883a5 100644 --- a/addons/default/visiosoft/location-module/src/Village/VillageModel.php +++ b/addons/default/visiosoft/location-module/src/Village/VillageModel.php @@ -5,15 +5,5 @@ use Anomaly\Streams\Platform\Model\Location\LocationVillageEntryModel; class VillageModel extends LocationVillageEntryModel implements VillageInterface { - public function getVillages() { - return VillageModel::all(); - } - public function getSubVillages($neighborhood) { - return $this->query()->where('parent_neighborhood_id', $neighborhood)->orderBy('order','ASC')->get(); - } - - public function deleteVillageByNeighborhood($id) { - $this->where('parent_neighborhood_id',$id)->orderBy('id','DESC')->delete(); - } } diff --git a/addons/default/visiosoft/location-module/src/Village/VillageRepository.php b/addons/default/visiosoft/location-module/src/Village/VillageRepository.php index 4f7d64d9b..f3b7be1de 100644 --- a/addons/default/visiosoft/location-module/src/Village/VillageRepository.php +++ b/addons/default/visiosoft/location-module/src/Village/VillageRepository.php @@ -46,4 +46,9 @@ class VillageRepository extends EntryRepository implements VillageRepositoryInte ->orderBy($orderBy, $direction) ->get(); } + + public function getVillagesByNeighborhoodId($neighborhood) + { + return $this->newQuery()->where('parent_neighborhood_id', $neighborhood)->orderBy('order','ASC')->get(); + } } diff --git a/addons/default/visiosoft/media-field_type/phpunit.xml b/addons/default/visiosoft/media-field_type/phpunit.xml deleted file mode 100644 index 5e8b35e8d..000000000 --- a/addons/default/visiosoft/media-field_type/phpunit.xml +++ /dev/null @@ -1,27 +0,0 @@ - - - - - ./tests - - - - - ./src - - - - - - - - - diff --git a/addons/default/visiosoft/media-field_type/resources/css/imgList.css b/addons/default/visiosoft/media-field_type/resources/css/imgList.css index d044ad2c0..cd731886a 100644 --- a/addons/default/visiosoft/media-field_type/resources/css/imgList.css +++ b/addons/default/visiosoft/media-field_type/resources/css/imgList.css @@ -21,13 +21,13 @@ color: #fff; position: absolute; z-index: 15; - right: 0px; - top: 0px; + right: 0; + top: 0; } -#setimage { +#setimage,#rotateImage,#deleteImage { padding: 9px 10px; color: white; - border-radius: 0px; + border-radius: 0; font-weight: bold; } /*Mobil Modu*/ diff --git a/addons/default/visiosoft/media-field_type/resources/lang/en/button.php b/addons/default/visiosoft/media-field_type/resources/lang/en/button.php index 5410f83cd..65c4a8a82 100644 --- a/addons/default/visiosoft/media-field_type/resources/lang/en/button.php +++ b/addons/default/visiosoft/media-field_type/resources/lang/en/button.php @@ -2,4 +2,6 @@ return [ 'showOn' => 'Main', + 'rotate' => 'Rotate', + 'delete' => 'Delete' ]; diff --git a/addons/default/visiosoft/media-field_type/resources/lang/tr/button.php b/addons/default/visiosoft/media-field_type/resources/lang/tr/button.php index e8fb1e78d..a570f8ac5 100644 --- a/addons/default/visiosoft/media-field_type/resources/lang/tr/button.php +++ b/addons/default/visiosoft/media-field_type/resources/lang/tr/button.php @@ -2,4 +2,6 @@ return [ 'showOn' => 'Vitrin', + 'rotate' => 'Döndür', + 'delete' => 'Sil' ]; diff --git a/addons/default/visiosoft/media-field_type/resources/views/table/table.twig b/addons/default/visiosoft/media-field_type/resources/views/table/table.twig index d2803a7b9..b67cca5b0 100644 --- a/addons/default/visiosoft/media-field_type/resources/views/table/table.twig +++ b/addons/default/visiosoft/media-field_type/resources/views/table/table.twig @@ -7,20 +7,13 @@ {% endif %}
        - - {% block panel %} -
        - -
        - {% block body %} - {{ view("visiosoft.field_type.media::table/partials/body", {'table': table}) }} - {% endblock %} -
        - + {% block panel %} +
        +
        + {% block body %} + {{ view("visiosoft.field_type.media::table/partials/body", {'table': table}) }} + {% endblock %}
        - {% endblock %} - - - - +
        + {% endblock %}
        diff --git a/addons/default/visiosoft/media-field_type/src/FilesFieldType.php b/addons/default/visiosoft/media-field_type/src/MediaFieldType.php similarity index 100% rename from addons/default/visiosoft/media-field_type/src/FilesFieldType.php rename to addons/default/visiosoft/media-field_type/src/MediaFieldType.php diff --git a/addons/default/visiosoft/media-field_type/src/FilesFieldTypeAccessor.php b/addons/default/visiosoft/media-field_type/src/MediaFieldTypeAccessor.php similarity index 100% rename from addons/default/visiosoft/media-field_type/src/FilesFieldTypeAccessor.php rename to addons/default/visiosoft/media-field_type/src/MediaFieldTypeAccessor.php diff --git a/addons/default/visiosoft/media-field_type/src/FilesFieldTypeSchema.php b/addons/default/visiosoft/media-field_type/src/MediaFieldTypeSchema.php similarity index 100% rename from addons/default/visiosoft/media-field_type/src/FilesFieldTypeSchema.php rename to addons/default/visiosoft/media-field_type/src/MediaFieldTypeSchema.php diff --git a/addons/default/visiosoft/media-field_type/src/FilesFieldTypeServiceProvider.php b/addons/default/visiosoft/media-field_type/src/MediaFieldTypeServiceProvider.php similarity index 100% rename from addons/default/visiosoft/media-field_type/src/FilesFieldTypeServiceProvider.php rename to addons/default/visiosoft/media-field_type/src/MediaFieldTypeServiceProvider.php diff --git a/addons/default/visiosoft/media-field_type/src/Table/ValueTableBuilder.php b/addons/default/visiosoft/media-field_type/src/Table/ValueTableBuilder.php index 7dc77212f..b28711e12 100644 --- a/addons/default/visiosoft/media-field_type/src/Table/ValueTableBuilder.php +++ b/addons/default/visiosoft/media-field_type/src/Table/ValueTableBuilder.php @@ -44,6 +44,7 @@ class ValueTableBuilder extends TableBuilder */ protected $columns = [ 'path' => '{entry.path}', +// 'path' => '', ]; /** @@ -65,12 +66,12 @@ class ValueTableBuilder extends TableBuilder ], 'rotate' => [ 'target' => '_blank', - 'icon' => 'fa fa-repeat', + 'icon' => 'fa fa-sync-alt', 'type' => 'info', 'text' => '', 'class' => 'col-4', 'attributes' => [ - 'id' => 'setimage', + 'id' => 'rotateImage', 'onclick' => 'rotateImage(event, {entry.id})', ], ], @@ -78,11 +79,11 @@ class ValueTableBuilder extends TableBuilder 'target' => '_blank', 'icon' => 'fa fa-trash', 'type' => 'danger', - 'text' => '', + 'text' => 'visiosoft.field_type.media::button.delete', 'class' => 'col-4 deleteImage', 'attributes' => [ 'onclick' => 'deleteImage(event, {entry.id})', - 'id' => 'setimage', + 'id' => 'deleteImage', ], ], ]; @@ -96,8 +97,8 @@ class ValueTableBuilder extends TableBuilder 'limit' => 9999, 'show_headers' => false, 'sortable_headers' => false, - 'table_view' => 'visiosoft.field_type.media::table/table', 'no_results_message' => 'visiosoft.field_type.media::message.no_files_selected', + 'table_view' => 'visiosoft.field_type.media::table/table' ]; /** diff --git a/addons/default/visiosoft/profile-module/migrations/2020_10_15_122457_visiosoft.module.profile__create_birthday_field.php b/addons/default/visiosoft/profile-module/migrations/2020_10_15_122457_visiosoft.module.profile__create_birthday_field.php index c4741b263..60e17da67 100644 --- a/addons/default/visiosoft/profile-module/migrations/2020_10_15_122457_visiosoft.module.profile__create_birthday_field.php +++ b/addons/default/visiosoft/profile-module/migrations/2020_10_15_122457_visiosoft.module.profile__create_birthday_field.php @@ -4,7 +4,6 @@ use Anomaly\Streams\Platform\Database\Migration\Migration; class VisiosoftModuleProfileCreateBirthdayField extends Migration { - /** * Run the migrations. * @@ -20,8 +19,8 @@ class VisiosoftModuleProfileCreateBirthdayField extends Migration ->first(); if (!$field) { - $field = $this->fields()->create([ - 'name' => trans('visiosoft.module.profile::field.birthday.name'), + $field = $this->fields()->newQuery()->create([ + 'name' => 'visiosoft.module.profile::field.birthday.name', 'namespace' => 'users', 'slug' => 'birthday', 'type' => 'anomaly.field_type.datetime', @@ -32,7 +31,7 @@ class VisiosoftModuleProfileCreateBirthdayField extends Migration ] ]); - $this->assignments()->create([ + $this->assignments()->newQuery()->create([ 'stream_id' => $stream->id, 'field_id' => $field->id ]); @@ -47,10 +46,5 @@ class VisiosoftModuleProfileCreateBirthdayField extends Migration */ public function down() { - /* - * I never go back on my word! - * That's my nindo: my ninja way! - * NARUTO - */ } } diff --git a/addons/default/visiosoft/profile-module/migrations/2021_03_31_121019_visiosoft.module.profile__add_index_table.php b/addons/default/visiosoft/profile-module/migrations/2021_03_31_121019_visiosoft.module.profile__add_index_table.php index bfa9683c2..c47aec73a 100644 --- a/addons/default/visiosoft/profile-module/migrations/2021_03_31_121019_visiosoft.module.profile__add_index_table.php +++ b/addons/default/visiosoft/profile-module/migrations/2021_03_31_121019_visiosoft.module.profile__add_index_table.php @@ -8,11 +8,12 @@ class VisiosoftModuleProfileAddIndexTable extends Migration { public function up() { - Schema::table('files_files', function (Blueprint $table) { - $table->index('deleted_at'); - $table->index('name'); - $table->index('folder_id'); - }); + // it broke installation + // Schema::table('files_files', function (Blueprint $table) { + // $table->index('deleted_at'); + // $table->index('name'); + // $table->index('folder_id'); + // }); } } diff --git a/addons/default/visiosoft/profile-module/src/advListingPage.sql b/addons/default/visiosoft/profile-module/src/advListingPage.sql deleted file mode 100644 index 52d2b239f..000000000 --- a/addons/default/visiosoft/profile-module/src/advListingPage.sql +++ /dev/null @@ -1,23 +0,0 @@ -SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO"; -SET AUTOCOMMIT = 0; -START TRANSACTION; -SET time_zone = "+00:00"; - -/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; -/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; -/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; -/*!40101 SET NAMES utf8mb4 */; - - -INSERT INTO `default_files_files` (`id`, `sort_order`, `created_at`, `created_by_id`, `updated_at`, `updated_by_id`, `deleted_at`, `name`, `disk_id`, `folder_id`, `extension`, `size`, `mime_type`, `entry_id`, `entry_type`, `keywords`, `height`, `width`, `alt_text`, `title`, `caption`, `description`) VALUES -(135, 1, '2019-08-08 07:35:41', 1, '2019-08-08 07:35:41', 1, NULL, 'adv-clothes.png', 1, 3, 'png', 213372, 'image/png', NULL, 'Anomaly\\Streams\\Platform\\Model\\Files\\FilesAdvListingPageEntryModel', NULL, '334', '1000', NULL, NULL, NULL, NULL), -(136, 2, '2019-08-08 07:35:45', 1, '2019-08-08 07:35:45', 1, NULL, 'adv-clothes2.png', 1, 3, 'png', 262373, 'image/png', NULL, 'Anomaly\\Streams\\Platform\\Model\\Files\\FilesAdvListingPageEntryModel', NULL, '334', '1000', NULL, NULL, NULL, NULL), -(137, 3, '2019-08-08 07:35:49', 1, '2019-08-08 07:35:49', 1, NULL, 'adv-electronics.png', 1, 3, 'png', 156843, 'image/png', NULL, 'Anomaly\\Streams\\Platform\\Model\\Files\\FilesAdvListingPageEntryModel', NULL, '334', '1000', NULL, NULL, NULL, NULL), -(138, 4, '2019-08-08 07:35:52', 1, '2019-08-08 07:35:52', 1, NULL, 'adv-electronics2.png', 1, 3, 'png', 189120, 'image/png', NULL, 'Anomaly\\Streams\\Platform\\Model\\Files\\FilesAdvListingPageEntryModel', NULL, '334', '1000', NULL, NULL, NULL, NULL), -(139, 5, '2019-08-08 07:35:57', 1, '2019-08-08 07:35:57', 1, NULL, 'adv-realestate.png', 1, 3, 'png', 66675, 'image/png', NULL, 'Anomaly\\Streams\\Platform\\Model\\Files\\FilesAdvListingPageEntryModel', NULL, '333', '1000', NULL, NULL, NULL, NULL), -(140, 6, '2019-08-08 07:36:00', 1, '2019-08-08 07:36:00', 1, NULL, 'adv-realestate2.png', 1, 3, 'png', 121117, 'image/png', NULL, 'Anomaly\\Streams\\Platform\\Model\\Files\\FilesAdvListingPageEntryModel', NULL, '334', '1000', NULL, NULL, NULL, NULL); -COMMIT; - -/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; -/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; -/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; diff --git a/addons/default/visiosoft/singlefile-field_type/phpunit.xml b/addons/default/visiosoft/singlefile-field_type/phpunit.xml deleted file mode 100644 index 5e8b35e8d..000000000 --- a/addons/default/visiosoft/singlefile-field_type/phpunit.xml +++ /dev/null @@ -1,27 +0,0 @@ - - - - - ./tests - - - - - ./src - - - - - - - - - diff --git a/addons/default/visiosoft/singlefile-field_type/src/FileFieldType.php b/addons/default/visiosoft/singlefile-field_type/src/SinglefileFieldType.php similarity index 100% rename from addons/default/visiosoft/singlefile-field_type/src/FileFieldType.php rename to addons/default/visiosoft/singlefile-field_type/src/SinglefileFieldType.php diff --git a/addons/default/visiosoft/singlefile-field_type/src/FileFieldTypeModifier.php b/addons/default/visiosoft/singlefile-field_type/src/SinglefileFieldTypeModifier.php similarity index 100% rename from addons/default/visiosoft/singlefile-field_type/src/FileFieldTypeModifier.php rename to addons/default/visiosoft/singlefile-field_type/src/SinglefileFieldTypeModifier.php diff --git a/addons/default/visiosoft/singlefile-field_type/src/FileFieldTypeServiceProvider.php b/addons/default/visiosoft/singlefile-field_type/src/SinglefileFieldTypeServiceProvider.php similarity index 100% rename from addons/default/visiosoft/singlefile-field_type/src/FileFieldTypeServiceProvider.php rename to addons/default/visiosoft/singlefile-field_type/src/SinglefileFieldTypeServiceProvider.php diff --git a/addons/default/visiosoft/singlefile-field_type/src/Table/ValueTableBuilder.php b/addons/default/visiosoft/singlefile-field_type/src/Table/ValueTableBuilder.php index 9805cc021..39c49ba39 100644 --- a/addons/default/visiosoft/singlefile-field_type/src/Table/ValueTableBuilder.php +++ b/addons/default/visiosoft/singlefile-field_type/src/Table/ValueTableBuilder.php @@ -63,7 +63,7 @@ class ValueTableBuilder extends TableBuilder 'limit' => 1, 'show_headers' => false, 'sortable_headers' => false, - 'table_view' => 'visiosoft.field_type.singlefile::table', + 'table_view' => 'anomaly.field_type.file::table', 'no_results_message' => 'visiosoft.field_type.singlefile::message.no_file_selected', ]; diff --git a/app/Providers/BroadcastServiceProvider.php b/app/Providers/BroadcastServiceProvider.php index 0a22a5af2..1670987c1 100644 --- a/app/Providers/BroadcastServiceProvider.php +++ b/app/Providers/BroadcastServiceProvider.php @@ -7,7 +7,6 @@ use Illuminate\Support\ServiceProvider; class BroadcastServiceProvider extends ServiceProvider { - /** * Bootstrap any application services. * @@ -17,14 +16,6 @@ class BroadcastServiceProvider extends ServiceProvider { Broadcast::routes(); - /* - * Authenticate the user's personal channel... - */ - Broadcast::channel( - 'App.User.*', - function ($user, $userId) { - return (int)$user->id === (int)$userId; - } - ); + require base_path('routes/channels.php'); } -} +} \ No newline at end of file diff --git a/composer.json b/composer.json index f4ff8997a..269cc7c31 100644 --- a/composer.json +++ b/composer.json @@ -1,139 +1,142 @@ { - "name": "openclassify/openclassify", - "description": "OpenClassify is the extensible and most advanced open source classified app build with Laravel.", - "type": "project", - "keywords": [ - "OpenClassify", - "classified", - "open Classify" - ], - "license": "MIT", - "authors": [ - { - "name": "Visiosoft, Inc.", - "email": "support@visiosoft.com.tr" - } - ], - "require": { - "wikimedia/composer-merge-plugin": "~1.4.0", - "anomaly/streams-composer-plugin": "~1.1.0", - "visiosoft/streams-platform": "^1.7", - "anomaly/default_authenticator-extension": "~2.1.0", - "anomaly/throttle_security_check-extension": "~2.1.0", - "anomaly/private_storage_adapter-extension": "~1.0.0", - "anomaly/default_page_handler-extension": "~2.1.0", - "anomaly/user_security_check-extension": "~2.1.0", - "anomaly/xml_feed_widget-extension": "~2.1.0", - "anomaly/page_link_type-extension": "~2.1.0", - "anomaly/url_link_type-extension": "~2.1.0", - "anomaly/relationship-field_type": "~2.2.0", - "anomaly/colorpicker-field_type": "~2.3.0", - "anomaly/polymorphic-field_type": "~2.1.0", - "anomaly/checkboxes-field_type": "~2.4.0", - "anomaly/encrypted-field_type": "~2.1.0", - "anomaly/datetime-field_type": "~3.0.0", - "anomaly/repeater-field_type": "~1.3.0", - "anomaly/language-field_type": "~2.2.0", - "anomaly/multiple-field_type": "~2.3.0", - "anomaly/textarea-field_type": "~2.1.0", - "anomaly/markdown-field_type": "~3.1.0", - "anomaly/wysiwyg-field_type": "~3.1.0", - "anomaly/boolean-field_type": "~2.3.0", - "anomaly/country-field_type": "~2.3.0", - "anomaly/decimal-field_type": "~2.1.0", - "anomaly/integer-field_type": "~2.1.0", - "anomaly/editor-field_type": "~3.1.0", - "anomaly/select-field_type": "~2.3.0", - "anomaly/slider-field_type": "~3.0.0", - "anomaly/addon-field_type": "~2.2.0", - "anomaly/email-field_type": "~2.1.0", - "anomaly/state-field_type": "~2.3.0", - "anomaly/files-field_type": "~2.3.0", - "anomaly/tags-field_type": "~2.4.0", - "anomaly/slug-field_type": "~2.1.0", - "anomaly/text-field_type": "~2.2.0", - "anomaly/file-field_type": "~2.2.0", - "anomaly/url-field_type": "~2.2.0", - "anomaly/configuration-module": "~2.1.0", - "anomaly/preferences-module": "~2.2.0", - "anomaly/navigation-module": "~2.4.0", - "anomaly/dashboard-module": "~2.2.0", - "anomaly/redirects-module": "~2.3.0", - "anomaly/variables-module": "~2.4.0", - "anomaly/settings-module": "~2.4.0", - "anomaly/blocks-module": "~1.3.0", - "anomaly/search-module": "~3.0.0", - "anomaly/system-module": "~1.0.0", - "anomaly/users-module": "~2.5.0", - "anomaly/pages-module": "~2.6.0", - "anomaly/posts-module": "~2.6.0", - "anomaly/files-module": "~2.6.0", - "anomaly/contact-plugin": "~1.2.0", - "anomaly/helper-plugin": "~2.1.0", - "anomaly/robots-extension": "~2.1.0", - "anomaly/sitemap-extension": "~2.2.0", - "anomaly/html_block-extension": "~1.0.0", - "anomaly/wysiwyg_block-extension": "~1.0.0", - "ammadeuss/laravel-html-dom-parser": "^1.1", - "visiosoft/decimal-field_type": "~2.1.0", - "visiosoft/integer-field_type": "~2.1.0", - "visiosoft/list-field_type": "*", - "guzzlehttp/guzzle": "~6.3.3", - "composer/composer": "^1.6" - }, - "replace": { - "anomaly/streams-platform": "*" - }, - "require-dev": { - "filp/whoops": "~2.0", - "phpunit/phpunit": "^7.0", - "fzaninotto/faker": "~1.4", - "mockery/mockery": "0.9.*", - "symfony/css-selector": "3.1.*", - "symfony/dom-crawler": "3.1.*", - "anomaly/installer-module": "~2.3.0" - }, - "repositories": [ - { - "type": "composer", - "url": "https://packages.pyrocms.com" - }, - { - "type": "composer", - "url": "https://community.pyrocms.com" - } - ], - "autoload": { - "classmap": [ - "database" + "name": "openclassify/openclassify", + "description": "OpenClassify is the extensible and most advanced open source classified app build with Laravel.", + "type": "project", + "keywords": [ + "OpenClassify", + "classified", + "open Classify" ], - "psr-4": { - "App\\": "app/" - } - }, - "autoload-dev": { - "classmap": [ - "tests/TestCase.php" - ] - }, - "extra": { - "merge-plugin": { - "include": [ - "addons/*/*/*/composer.json", - "core/*/*/composer.json" - ], - "recurse": true, - "replace": false + "license": "MIT", + "authors": [ + { + "name": "Visiosoft, Inc.", + "email": "support@visiosoft.com.tr" + } + ], + "require": { + "visiosoft/streams-platform": "~1.9.0", + "anomaly/xml_feed_widget-extension": "~2.1.0", + "anomaly/default_authenticator-extension": "~2.1.0", + "anomaly/throttle_security_check-extension": "~2.1.0", + "anomaly/private_storage_adapter-extension": "~1.1.0", + "anomaly/default_page_handler-extension": "~2.1.0", + "anomaly/user_security_check-extension": "~2.1.0", + "anomaly/page_link_type-extension": "~2.1.0", + "anomaly/url_link_type-extension": "~2.1.0", + "anomaly/relationship-field_type": "~2.2.0", + "anomaly/colorpicker-field_type": "~2.3.0", + "anomaly/polymorphic-field_type": "~2.1.0", + "anomaly/checkboxes-field_type": "~2.4.0", + "anomaly/encrypted-field_type": "~2.1.0", + "anomaly/datetime-field_type": "~3.0.0", + "anomaly/repeater-field_type": "~1.3.0", + "anomaly/language-field_type": "~2.2.0", + "anomaly/multiple-field_type": "~2.3.0", + "anomaly/textarea-field_type": "~2.1.0", + "anomaly/markdown-field_type": "~3.1.0", + "anomaly/wysiwyg-field_type": "~3.1.0", + "anomaly/boolean-field_type": "~2.3.0", + "anomaly/country-field_type": "~2.3.0", + "anomaly/decimal-field_type": "~2.1.0", + "anomaly/integer-field_type": "~2.1.0", + "anomaly/editor-field_type": "~3.1.0", + "anomaly/select-field_type": "~2.3.0", + "anomaly/slider-field_type": "~3.0.0", + "anomaly/addon-field_type": "~2.2.0", + "anomaly/email-field_type": "~2.1.0", + "anomaly/state-field_type": "~2.3.0", + "anomaly/files-field_type": "~2.3.0", + "anomaly/tags-field_type": "~2.4.0", + "anomaly/slug-field_type": "~2.1.0", + "anomaly/text-field_type": "~2.2.0", + "anomaly/file-field_type": "~2.2.0", + "anomaly/url-field_type": "~2.2.0", + "anomaly/configuration-module": "~2.1.0", + "anomaly/preferences-module": "~2.2.0", + "anomaly/navigation-module": "~2.4.0", + "anomaly/dashboard-module": "~2.2.0", + "anomaly/redirects-module": "~2.3.0", + "anomaly/variables-module": "~2.4.0", + "anomaly/settings-module": "~2.4.0", + "anomaly/blocks-module": "~1.3.0", + "anomaly/search-module": "~3.0.0", + "anomaly/system-module": "~1.1.0", + "anomaly/users-module": "~2.5.0", + "anomaly/pages-module": "~2.6.0", + "anomaly/posts-module": "~2.6.0", + "anomaly/files-module": "~2.6.0", + "anomaly/contact-plugin": "~1.2.0", + "anomaly/helper-plugin": "~2.1.0", + "anomaly/robots-extension": "~2.1.0", + "anomaly/html_block-extension": "~1.0.0", + "anomaly/wysiwyg_block-extension": "~1.0.0", + "visiosoft/decimal-field_type": "~2.1.0", + "visiosoft/integer-field_type": "~2.1.0", + "visiosoft/list-field_type": "*", + "wirelab/language_switcher-plugin": "^1.3", + "visiosoft/addblock-extension": "^1.1", + "maatwebsite/excel": "*", + "google/recaptcha": "1.2.*", + "sentry/sentry-laravel": "2.3.1", + "composer/composer": "2.*", + "wikimedia/composer-merge-plugin": "2.*", + "pusher/pusher-php-server": "^5.0", + "laravel/framework": "v8.36.2", + "simplepie/simplepie": "^1.5.0", + "guzzlehttp/guzzle": "^7.3" }, - "laravel": { - "dont-discover": [ - "*" - ] + "replace": { + "anomaly/streams-platform": "*" + }, + "require-dev": { + "filp/whoops": "~2.0", + "fzaninotto/faker": "~1.4", + "symfony/css-selector": "3.1.*", + "symfony/dom-crawler": "3.1.*", + "anomaly/installer-module": "~2.4.0" + }, + "repositories": [ + { + "type": "composer", + "url": "https://packages.pyrocms.com" + }, + { + "type": "composer", + "url": "https://community.pyrocms.com" + } + ], + "autoload": { + "classmap": [ + "database" + ], + "psr-4": { + "App\\": "app/" + } + }, + "autoload-dev": { + "classmap": [ + "tests/TestCase.php" + ] + }, + "extra": { + "merge-plugin": { + "include": [ + "addons/*/*/*/composer.json", + "core/*/*/composer.json" + ], + "recurse": true, + "replace": false + }, + "laravel": { + "dont-discover": [ + "*" + ] + } + }, + "config": { + "bin-dir": "bin", + "preferred-install": "dist", + "optimize-autoloader": true } - }, - "config": { - "bin-dir": "bin", - "preferred-install": "dist", - "optimize-autoloader": true - } } diff --git a/config/app.php b/config/app.php index 83cf80506..669168482 100644 --- a/config/app.php +++ b/config/app.php @@ -204,7 +204,7 @@ return [ */ App\Providers\AppServiceProvider::class, App\Providers\AuthServiceProvider::class, - // App\Providers\BroadcastServiceProvider::class, + App\Providers\BroadcastServiceProvider::class, App\Providers\EventServiceProvider::class, App\Providers\RouteServiceProvider::class, @@ -229,39 +229,41 @@ return [ 'aliases' => [ - 'App' => Illuminate\Support\Facades\App::class, - 'Artisan' => Illuminate\Support\Facades\Artisan::class, - 'Auth' => Illuminate\Support\Facades\Auth::class, - 'Blade' => Illuminate\Support\Facades\Blade::class, - 'Broadcast' => Illuminate\Support\Facades\Broadcast::class, - 'Bus' => Illuminate\Support\Facades\Bus::class, - 'Cache' => Illuminate\Support\Facades\Cache::class, - 'Config' => Illuminate\Support\Facades\Config::class, - 'Cookie' => Illuminate\Support\Facades\Cookie::class, - 'Crypt' => Illuminate\Support\Facades\Crypt::class, - 'DB' => Illuminate\Support\Facades\DB::class, - 'Eloquent' => Illuminate\Database\Eloquent\Model::class, - 'Event' => Illuminate\Support\Facades\Event::class, - 'File' => Illuminate\Support\Facades\File::class, - 'Gate' => Illuminate\Support\Facades\Gate::class, - 'Hash' => Illuminate\Support\Facades\Hash::class, - 'Lang' => Illuminate\Support\Facades\Lang::class, - 'Log' => Illuminate\Support\Facades\Log::class, - 'Mail' => Illuminate\Support\Facades\Mail::class, + 'App' => Illuminate\Support\Facades\App::class, + 'Arr' => Illuminate\Support\Arr::class, + 'Artisan' => Illuminate\Support\Facades\Artisan::class, + 'Auth' => Illuminate\Support\Facades\Auth::class, + 'Blade' => Illuminate\Support\Facades\Blade::class, + 'Broadcast' => Illuminate\Support\Facades\Broadcast::class, + 'Bus' => Illuminate\Support\Facades\Bus::class, + 'Cache' => Illuminate\Support\Facades\Cache::class, + 'Config' => Illuminate\Support\Facades\Config::class, + 'Cookie' => Illuminate\Support\Facades\Cookie::class, + 'Crypt' => Illuminate\Support\Facades\Crypt::class, + 'DB' => Illuminate\Support\Facades\DB::class, + 'Eloquent' => Illuminate\Database\Eloquent\Model::class, + 'Event' => Illuminate\Support\Facades\Event::class, + 'File' => Illuminate\Support\Facades\File::class, + 'Gate' => Illuminate\Support\Facades\Gate::class, + 'Hash' => Illuminate\Support\Facades\Hash::class, + 'Lang' => Illuminate\Support\Facades\Lang::class, + 'Log' => Illuminate\Support\Facades\Log::class, + 'Mail' => Illuminate\Support\Facades\Mail::class, 'Notification' => Illuminate\Support\Facades\Notification::class, - 'Password' => Illuminate\Support\Facades\Password::class, - 'Queue' => Illuminate\Support\Facades\Queue::class, - 'Redirect' => Illuminate\Support\Facades\Redirect::class, - 'Redis' => Illuminate\Support\Facades\Redis::class, - 'Request' => Illuminate\Support\Facades\Request::class, - 'Response' => Illuminate\Support\Facades\Response::class, - 'Route' => Illuminate\Support\Facades\Route::class, - 'Schema' => Illuminate\Support\Facades\Schema::class, - 'Session' => Illuminate\Support\Facades\Session::class, - 'Storage' => Illuminate\Support\Facades\Storage::class, - 'URL' => Illuminate\Support\Facades\URL::class, - 'Validator' => Illuminate\Support\Facades\Validator::class, - 'View' => Illuminate\Support\Facades\View::class, + 'Password' => Illuminate\Support\Facades\Password::class, + 'Queue' => Illuminate\Support\Facades\Queue::class, + 'Redirect' => Illuminate\Support\Facades\Redirect::class, + 'Redis' => Illuminate\Support\Facades\Redis::class, + 'Request' => Illuminate\Support\Facades\Request::class, + 'Response' => Illuminate\Support\Facades\Response::class, + 'Route' => Illuminate\Support\Facades\Route::class, + 'Schema' => Illuminate\Support\Facades\Schema::class, + 'Session' => Illuminate\Support\Facades\Session::class, + 'Storage' => Illuminate\Support\Facades\Storage::class, + 'Str' => Illuminate\Support\Str::class, + 'URL' => Illuminate\Support\Facades\URL::class, + 'Validator' => Illuminate\Support\Facades\Validator::class, + 'View' => Illuminate\Support\Facades\View::class, 'Sentry' => Sentry\Laravel\Facade::class, diff --git a/config/broadcasting.php b/config/broadcasting.php index 19a59bad9..47a8db467 100644 --- a/config/broadcasting.php +++ b/config/broadcasting.php @@ -15,7 +15,7 @@ return [ | */ - 'default' => env('BROADCAST_DRIVER', 'null'), + 'default' => env('BROADCAST_DRIVER', 'pusher'), /* |-------------------------------------------------------------------------- @@ -32,11 +32,19 @@ return [ 'pusher' => [ 'driver' => 'pusher', - 'key' => env('PUSHER_KEY'), - 'secret' => env('PUSHER_SECRET'), - 'app_id' => env('PUSHER_APP_ID'), + 'key' => env('PUSHER_APP_KEY', '12345'), + 'secret' => env('PUSHER_APP_SECRET', '12345'), + 'app_id' => env('PUSHER_APP_ID', '12345'), 'options' => [ - // + 'cluster' => env('PUSHER_APP_CLUSTER', 'mt1'), + 'encrypted' => env('BROADCAST_SSL', false), + 'host' => '127.0.0.1', + 'port' => 6001, + 'scheme' => env('BROADCAST_SSL', false) ? 'https' : 'http', + 'curl_options' => [ + CURLOPT_SSL_VERIFYHOST => 0, + CURLOPT_SSL_VERIFYPEER => 0, + ] ], ], diff --git a/config/logging.php b/config/logging.php index 372fc9e4b..d09cd7d29 100644 --- a/config/logging.php +++ b/config/logging.php @@ -91,4 +91,4 @@ return [ ], ], -]; \ No newline at end of file +]; diff --git a/config/scout.php b/config/scout.php index 1f7d58fce..7e88c58fa 100644 --- a/config/scout.php +++ b/config/scout.php @@ -15,7 +15,7 @@ return [ | */ - 'driver' => env('SCOUT_DRIVER', null), + 'driver' => env('SCOUT_DRIVER', 'search'), /* |-------------------------------------------------------------------------- @@ -58,7 +58,7 @@ return [ 'id' => env('ALGOLIA_APP_ID'), 'secret' => env('ALGOLIA_SECRET'), ], - + /* |-------------------------------------------------------------------------- | TNT Configuration diff --git a/config/streams.php b/config/streams.php index 190a1d821..e666da0e0 100644 --- a/config/streams.php +++ b/config/streams.php @@ -3,7 +3,7 @@ use App\Exceptions\ExceptionHandler; return [ - + /* |-------------------------------------------------------------------------- | Listeners @@ -15,7 +15,7 @@ return [ 'listeners' => [ \Anomaly\Streams\Platform\Event\Booted::class => [ - \App\Listeners\Translations::class + // \App\Listeners\Translations::class ], \Anomaly\Streams\Platform\Ui\Form\Event\FormWasSaved::class => [ \App\Listeners\EnableMaintenanceMode::class @@ -32,7 +32,7 @@ return [ */ 'bindings' => [ - 'Anomaly\Streams\Platform\Exception\ExceptionHandler' => ExceptionHandler::class + // 'Anomaly\Streams\Platform\Exception\ExceptionHandler' => ExceptionHandler::class ], /* @@ -129,7 +129,7 @@ return [ */ 'middleware_priority' => [], - + /* |-------------------------------------------------------------------------- | View Overrides @@ -140,7 +140,7 @@ return [ */ 'overrides' => [], - + /* |-------------------------------------------------------------------------- | Control Panel Customization diff --git a/database/seeds/DatabaseSeeder.php b/database/seeds/DatabaseSeeder.php index 744f86f10..7ca7321fa 100644 --- a/database/seeds/DatabaseSeeder.php +++ b/database/seeds/DatabaseSeeder.php @@ -112,7 +112,7 @@ class DatabaseSeeder extends Seeder ] ); - $repository = "https://raw.githubusercontent.com/openclassify/Openclassify-Demo-Data/master/"; + $repository = "https://raw.githubusercontent.com/openclassify/Openclassify-Demo-Data/upgrade3.8/"; file_put_contents(storage_path('advs.sql'), fopen($repository . "advs.sql", 'r')); file_put_contents(storage_path('settings.sql'), fopen($repository . "settings.sql", 'r')); file_put_contents(storage_path('categories.sql'), fopen($repository . "categories.sql", 'r')); @@ -194,6 +194,21 @@ class DatabaseSeeder extends Seeder ]); }; + + //Create Category Icon Folder + if (!$this->folders->findBySlug('category_icon')) { + $disk = $this->disks->findBySlug('local'); + + $this->folders->create([ + 'en' => [ + 'name' => 'Category Icon', + 'description' => 'A folder for Category Icon.', + ], + 'slug' => 'category_icon', + 'disk' => $disk + ]); + }; + Artisan::call('assets:clear'); } } diff --git a/resources/streams/config/addons.php b/resources/streams/config/addons.php index 4b16fcd2d..a3f0b464e 100644 --- a/resources/streams/config/addons.php +++ b/resources/streams/config/addons.php @@ -13,7 +13,6 @@ return [ */ 'eager' => [ - 'core/anomaly/sitemap-extension', 'core/anomaly/settings-module', 'core/anomaly/preferences-module' ], diff --git a/routes/channels.php b/routes/channels.php new file mode 100644 index 000000000..5d451e1fa --- /dev/null +++ b/routes/channels.php @@ -0,0 +1,18 @@ +id === (int) $id; +});