fixed upgrade errors && cat icon fixed

This commit is contained in:
vedatakd 2021-04-14 12:15:09 +03:00
parent 0e8bd9435e
commit 67b331e4f7
8 changed files with 25 additions and 16 deletions

View File

@ -9,10 +9,8 @@
{% endif %} {% endif %}
{% endfor %} {% endfor %}
{% endif %} {% endif %}
{% if setting_value('visiosoft.module.advs::hide_price_filter') == false and not isHidden %}
{% if setting_value('visiosoft.module.advs::hide_price_filter') == false and not isHidden%}
{% set hidePriceCats = setting_value('visiosoft.module.advs::hide_price_categories') %}
{% set cats = entries('cats','category').whereIn('id', hidePriceCats).get() %}
{% set active_currencies = setting_value('visiosoft.module.advs::enabled_currencies') %} {% set active_currencies = setting_value('visiosoft.module.advs::enabled_currencies') %}
<div id="price" class="border rounded filter-box p-3 mb-3"> <div id="price" class="border rounded filter-box p-3 mb-3">

View File

@ -1,9 +1,7 @@
<ul class="categories-list px-0 mr-2 d-block d-sm-none"> <ul class="categories-list px-0 mr-2 d-block d-sm-none">
<li class="categories-list-li category-icon text-truncate category-{{ main_category.slug }}"> <li class="categories-list-li category-icon text-truncate category-{{ main_category.slug }}">
<a href="{{ url_route('adv_list_seo', [main_category.slug]) }}" class="main-category"> <a href="{{ url_route('adv_list_seo', [main_category.slug]) }}" class="main-category">
{% set icon = img(url('local://category_icon/'~main_category.id~'.png')) %} {% set categoryIcon = (main_category.icon) ? main_category.icon : img('visiosoft.theme.base::images/default-categories-icon.png').url %}
{% set categoryIcon = (icon.data()) ? icon.url() : img('visiosoft.theme.base::images/default-categories-icon.png').url %}
<img src="{{ categoryIcon }}" alt="{{ main_category.name }}" class="img-responsive"> <img src="{{ categoryIcon }}" alt="{{ main_category.name }}" class="img-responsive">
<span>{{ main_category.name }}</span> <span>{{ main_category.name }}</span>
<p class="p-0 sub-categories"> <p class="p-0 sub-categories">

View File

@ -1,8 +1,6 @@
<ul class="categories-list p-0 d-none d-sm-block"> <ul class="categories-list p-0 d-none d-sm-block">
<li class="categories-list-li category-icon category-{{ main_category.slug }}"> <li class="categories-list-li category-icon category-{{ main_category.slug }}">
{% set categoryIcon = (main_category.icon) ? main_category.icon : img('visiosoft.theme.base::images/default-categories-icon.png').url %}
{% set icon = img(url('local://category_icon/'~main_category.id~'.png')) %}
{% set categoryIcon = (icon.data()) ? icon.url() : img('visiosoft.theme.base::images/default-categories-icon.png').url %}
<img src="{{ categoryIcon }}" alt="{{ main_category.name }}" class="img-responsive"> <img src="{{ categoryIcon }}" alt="{{ main_category.name }}" class="img-responsive">
<a href="{{ url_route('adv_list_seo', [main_category.slug]) }}" class="main-category"> <a href="{{ url_route('adv_list_seo', [main_category.slug]) }}" class="main-category">

View File

@ -5,11 +5,8 @@
<li> <li>
<div class="d-flex"> <div class="d-flex">
{% if (not categoryId) or (loop.first and categoryId) %} {% if (not categoryId) or (loop.first and categoryId) %}
{# {% if maincat.icon %}#} {% set categoryIcon = (maincat.icon) ? maincat.icon : img('visiosoft.module.advs::images/listing/sample-cat-icon.svg').url %}
{# <img src="{{ maincat.icon.url }}" alt="{{ maincat.name }}">#} <img src="{{ categoryIcon }}" alt="{{ main_category.name }}" class="img-responsive">
{# {% else %}#}
{{ img('visiosoft.module.advs::images/listing/sample-cat-icon.svg').data|raw }}
{# {% endif %}#}
{% endif %} {% endif %}
<div class="{{ not loop.first and categoryId ? 'sub-cat' : 'ml-2' }}" style="{{ not loop.first and categoryId ? 'padding-left: ' ~ (loop.index - 1) * 0.5 ~ 'rem;' }}"> <div class="{{ not loop.first and categoryId ? 'sub-cat' : 'ml-2' }}" style="{{ not loop.first and categoryId ? 'padding-left: ' ~ (loop.index - 1) * 0.5 ~ 'rem;' }}">
<a href="{{ appendRequestURL(request_query(),url_route('adv_list_seo', [maincat.slug, cityId.slug]),{},['page']) }}"> <a href="{{ appendRequestURL(request_query(),url_route('adv_list_seo', [maincat.slug, cityId.slug]),{},['page']) }}">

View File

@ -59,4 +59,9 @@ class CategoryModel extends CatsCategoryEntryModel implements CategoryInterface
unset($categories[count($categories) - 1]); unset($categories[count($categories) - 1]);
return $categories; return $categories;
} }
public function setCategoryIconUrl($url)
{
$this->update(['icon' => $url]);
}
} }

View File

@ -48,6 +48,7 @@ class CategoryRepository extends EntryRepository implements CategoryRepositoryIn
->select( ->select(
DB::raw('c1.id'), DB::raw('c1.id'),
DB::raw('c1.slug'), DB::raw('c1.slug'),
DB::raw('c1.icon'),
DB::raw('c1.count'), DB::raw('c1.count'),
DB::raw('c1.parent_category_id'), DB::raw('c1.parent_category_id'),
DB::raw('t1.name'), DB::raw('t1.name'),

View File

@ -11,4 +11,6 @@ interface CategoryInterface extends EntryInterface
public function getParent(); public function getParent();
public function getMains($id); public function getMains($id);
public function setCategoryIconUrl($url);
} }

View File

@ -248,18 +248,28 @@ class CategoryController extends AdminController
$folderRepository = app(FolderRepositoryInterface::class); $folderRepository = app(FolderRepositoryInterface::class);
$manager = app(MountManager::class); $manager = app(MountManager::class);
if ($file = $this->request->file('icon') and $folder = $folderRepository->findBySlug('category_icon')) { if ($file = $this->request->file('icon') and $folder = $folderRepository->findBySlug('category_icon') and $category = $this->categoryRepository->find($category_id)) {
$type = explode('.', $file->getClientOriginalName()); $type = explode('.', $file->getClientOriginalName());
$type = end($type); $type = end($type);
$file_location = $folder->getDisk()->getSlug() . '://' . $folder->getSlug() . '/' . FileSanitizer::clean($category_id . "." . $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)) { if (Storage::exists($file_location)) {
Storage::delete($file_location); Storage::delete($file_location);
} }
try {
$manager->put($file_location, file_get_contents($file->getRealPath())); $manager->put($file_location, file_get_contents($file->getRealPath()));
$category->setCategoryIconUrl($file_url);
} catch (\Exception $exception) {
$this->messages->error([$exception->getMessage()]);
}
} }
} }