#765 added url parameters for link

This commit is contained in:
vedatakd 2020-02-12 10:15:44 +03:00
parent 5b9056bdc5
commit dc7922dd41
5 changed files with 118 additions and 13 deletions

View File

@ -47,7 +47,8 @@
</label>
</div>
<div class="form-check py-1">
<input class="form-check-input" type="radio" name="date" id="dateMonth" value="month">
<input class="form-check-input" type="radio" name="date" id="dateMonth"
value="month">
<label class="form-check-label" for="dateMonth">
{{ trans("visiosoft.module.advs::field.in_the_last_month.name") }}
</label>
@ -64,7 +65,8 @@
<button class="btn btn-link text-dark" data-toggle="collapse" data-target="#media"
aria-expanded="true" aria-controls="media">
<i class="fa fa-camera"></i>
{{ trans("visiosoft.module.advs::field.photo.name") }}, {{ trans("visiosoft.module.advs::field.video.name") }}
{{ trans("visiosoft.module.advs::field.photo.name") }}
, {{ trans("visiosoft.module.advs::field.video.name") }}
</button>
</h5>
</div>
@ -73,13 +75,15 @@
style="max-height: 300px;">
<div class="row p-3 m-0">
<div class="form-check py-1">
<input class="form-check-input" type="checkbox" value="true" name="photo" id="photo">
<input class="form-check-input" type="checkbox" value="true" name="photo"
id="photo">
<label class="form-check-label" for="photo">
{{ trans("visiosoft.module.advs::field.ads_with_photo.name") }}
</label>
</div>
<div class="form-check py-1">
<input class="form-check-input" type="checkbox" value="true" name="video" id="video">
<input class="form-check-input" type="checkbox" value="true" name="video"
id="video">
<label class="form-check-label" for="video">
{{ trans("visiosoft.module.advs::field.ads_with_video.name") }}
</label>
@ -105,7 +109,8 @@
style="max-height: 300px;">
<div class="row p-3 m-0">
<div class="form-check py-1">
<input class="form-check-input" type="checkbox" value="true" name="map" id="mapFilter">
<input class="form-check-input" type="checkbox" value="true" name="map"
id="mapFilter">
<label class="form-check-label" for="mapFilter">
{{ trans("visiosoft.module.advs::field.yes.name") }}
</label>
@ -133,13 +138,13 @@
{% set active_currencies = setting_value('visiosoft.module.advs::enabled_currencies') %}
<div class="col-md-4 p-1 m-0">
<input type="number" class="price-input form-control w-100"
value="{{ request.min_price }}"
value="{{ app.request.get('min_price') }}"
name="min_price" min="0"
placeholder="{{ trans('visiosoft.module.advs::field.min.name') }}">
</div>
<div class="col-md-4 p-1 pr-0 m-0">
<input class="price-input form-control w-100" type="number"
value="{{ request.max_price }}"
value="{{ app.request.get('max_price') }}"
name="max_price"
placeholder="{{ trans('visiosoft.module.advs::field.max.name') }}">
@ -147,7 +152,9 @@
<div class="col-md-4 py-1 px-0">
<select name="currency" id="currency" class="form-control">
{% for currency in active_currencies %}
<option value="{{ currency }}">{{ currency }}</option>
<option {% if app.request.get('currency') == currency %}
selected
{% endif %}value="{{ currency }}">{{ currency }}</option>
{% endfor %}
</select>
</div>

View File

@ -0,0 +1,78 @@
<?php namespace Visiosoft\AdvsModule\Adv\Command;
use Illuminate\Support\Arr;
use Illuminate\Support\Str;
class appendRequestURL
{
protected $query = [];
protected $request;
protected $url;
protected $new_parameters;
/**
* appendRequestURL constructor.
* @param $request
*/
public function __construct($request, $url, $new_parameters = [])
{
$this->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;
}
}

View File

@ -1,6 +1,7 @@
<?php namespace Visiosoft\AdvsModule;
use Anomaly\Streams\Platform\Addon\Plugin\Plugin;
use Visiosoft\AdvsModule\Adv\Command\appendRequestURL;
use Visiosoft\AdvsModule\Adv\Command\GetAd;
use Visiosoft\AdvsModule\Adv\Command\isActive;
use Visiosoft\AdvsModule\Adv\Command\LatestAds;
@ -44,6 +45,13 @@ class AdvsModulePlugin extends Plugin
return $latestAds;
}
),
new \Twig_SimpleFunction(
'appendRequestURL',
function ($request, $url, $new_parameters) {
return $this->dispatch(new appendRequestURL($request, $url, $new_parameters));
}
)
];
}

View File

@ -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')

View File

@ -21,7 +21,13 @@
{% set id = maincat.id %}
{% set parent_category = false %}
{% endif %}
<a href="{% if(type == "list") %}{{ url_route('visiosoft.module.advs::list') }}{% else %}{{ url_route('advs_map_list') }}{% endif %}?cat={{ id }}"
<a href="
{% if(viewType != "map") %}
{{ appendRequestURL(request_query(),url_route('visiosoft.module.advs::list'),{'cat':id}) }}
{% else %}
{{ appendRequestURL(request_query(),url_route('advs_map_list'),{'cat':id}) }}
{% endif %}
"
class="list-group-item list-group-item-action text-truncate">
<i class="fas fa-dot-circle"></i>
{{ name }}
@ -29,7 +35,13 @@
{% for subcat in params.subCats %}
<div class="list-group pl-3 bg-light">
{% if subcat.parent_category_id == maincat['id'] %}
<a href="{% if(type == "list") %}{{ url_route('visiosoft.module.advs::list') }}{% else %}{{ url_route('advs_map_list') }}{% endif %}?cat={{ subcat.id }}"
<a href="
{% if(viewType != "map") %}
{{ appendRequestURL(request_query(),url_route('visiosoft.module.advs::list'),{'cat':subcat.id}) }}
{% else %}
{{ appendRequestURL(request_query(),url_route('advs_map_list'),{'cat':subcat.id}) }}
{% endif %}
"
class="list-group-item list-group-item-action
text-truncate">{{ subcat.name }}</a>
{% endif %}