From dc7922dd417cc46236fa0d53c205f68fa75ef8ca Mon Sep 17 00:00:00 2001 From: vedatakd Date: Wed, 12 Feb 2020 10:15:44 +0300 Subject: [PATCH] #765 added url parameters for link --- .../views/list/partials/list-filter.twig | 23 ++++-- .../src/Adv/Command/appendRequestURL.php | 78 +++++++++++++++++++ .../advs-module/src/AdvsModulePlugin.php | 8 ++ .../src/Http/Controller/advsController.php | 6 +- .../views/ads-list/partials/list-filter.twig | 16 +++- 5 files changed, 118 insertions(+), 13 deletions(-) create mode 100644 addons/default/visiosoft/advs-module/src/Adv/Command/appendRequestURL.php 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 4d3e812a5..6185bc537 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 @@ -47,7 +47,8 @@
- + @@ -64,7 +65,8 @@
@@ -73,13 +75,15 @@ style="max-height: 300px;">
- +
- + @@ -105,7 +109,8 @@ style="max-height: 300px;">
- + @@ -133,13 +138,13 @@ {% set active_currencies = setting_value('visiosoft.module.advs::enabled_currencies') %}
@@ -147,7 +152,9 @@
diff --git a/addons/default/visiosoft/advs-module/src/Adv/Command/appendRequestURL.php b/addons/default/visiosoft/advs-module/src/Adv/Command/appendRequestURL.php new file mode 100644 index 000000000..03715dba0 --- /dev/null +++ b/addons/default/visiosoft/advs-module/src/Adv/Command/appendRequestURL.php @@ -0,0 +1,78 @@ +url = $url; + $this->request = $request; + $this->new_parameters = $new_parameters; + } + + /** + * @return appendRequestURL + */ + public function handle() + { + return $this->url + . (Str::contains($this->url, '?') ? '&' : '?') + . Arr::query($this->appends(array_merge($this->request, $this->new_parameters))); + } + + /** + * @param $key + * @param null $value + * @return $this|appendRequestURL + */ + public function appends($key, $value = null) + { + if (is_null($key)) { + return $this->query; + } + + if (is_array($key)) { + return $this->appendArray($key)->query; + } + + return $this->addQuery($key, $value)->query; + } + + /** + * @param array $keys + * @return $this + */ + protected function appendArray(array $keys) + { + foreach ($keys as $key => $value) { + $this->addQuery($key, $value); + } + + return $this; + } + + /** + * @param $key + * @param $value + * @return $this + */ + protected function addQuery($key, $value) + { + $this->query[$key] = $value; + + return $this; + } +} diff --git a/addons/default/visiosoft/advs-module/src/AdvsModulePlugin.php b/addons/default/visiosoft/advs-module/src/AdvsModulePlugin.php index cfbb7fd70..da7789d85 100644 --- a/addons/default/visiosoft/advs-module/src/AdvsModulePlugin.php +++ b/addons/default/visiosoft/advs-module/src/AdvsModulePlugin.php @@ -1,6 +1,7 @@ dispatch(new appendRequestURL($request, $url, $new_parameters)); + } ) ]; } diff --git a/addons/default/visiosoft/advs-module/src/Http/Controller/advsController.php b/addons/default/visiosoft/advs-module/src/Http/Controller/advsController.php index 531a61bc9..7ed8f86bd 100644 --- a/addons/default/visiosoft/advs-module/src/Http/Controller/advsController.php +++ b/addons/default/visiosoft/advs-module/src/Http/Controller/advsController.php @@ -214,13 +214,13 @@ class AdvsController extends PublicController $userProfile = $this->profile_repository->getProfile($user->id); } - $compact = compact('advs', 'countries', 'mainCats', 'subCats', 'checkboxes', 'request', - 'user', 'userProfile', 'featured_advs', 'type', 'topfields', 'ranges', 'seenList', 'searchedCountry', 'radio'); - Cookie::queue(Cookie::make('last_search', $this->requestHttp->getRequestUri(), 84000)); $viewType = $this->requestHttp->cookie('viewType'); + $compact = compact('advs', 'countries', 'mainCats', 'subCats', 'checkboxes', 'request', + 'user', 'userProfile', 'featured_advs', 'viewType', 'topfields', 'ranges', 'seenList', 'searchedCountry', 'radio'); + if (isset($viewType) and $viewType == 'table') return $this->view->make('visiosoft.module.advs::list/table', $compact); elseif (isset($viewType) and $viewType == 'map') 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 index 389a4dc08..c81d14f5c 100644 --- 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 @@ -21,7 +21,13 @@ {% set id = maincat.id %} {% set parent_category = false %} {% endif %} - {{ name }} @@ -29,7 +35,13 @@ {% for subcat in params.subCats %}