added categories fav image

pull/49/head
A1Gard 5 months ago
parent c51d84abae
commit eb4147a65e

@ -824,6 +824,19 @@ function getCategoryProductBySetting($key, $limit = 10, $order = 'id', $dir = "D
return Category::where('id', getSetting($key) ?? 1)->first()
->products()->where('status', 1)->orderBy($order, $dir)->limit($limit)->get();
}
/**
* get group's posts by setting key
* @param $key
* @param integer $limit
* @param string $order
* @param string $dir
* @return \App\Models\Post[]|\Illuminate\Database\Eloquent\Collection|\LaravelIdea\Helper\App\Models\_IH_Post_C
*/
function getCategorySubCatsBySetting($key, $limit = 10, $order = 'id', $dir = "DESC")
{
return Category::where('id', getSetting($key) ?? 1)->first()
->children()->orderBy($order, $dir)->limit($limit)->get();
}
/**
* @param null $data

@ -0,0 +1,21 @@
<section id='CategoriesFavImageLinks'>
<div class="{{gfx()['container']}}">
<h1>
{{getSetting($data->area->name.'_'.$data->part.'_title')}}
</h1>
<div id="brands-slider">
@foreach( getCategorySubCatsBySetting($data->area->name.'_'.$data->part.'_category',8) as $category )
<div class="item">
<a href="{{$category->webUrl()}}">
<img src="{{$category->imgUrl()}}" alt="{{$category->name}}" title="{{$category->title}}">
</a>
</div>
@endforeach
</div>
<div id="brand-nav-container">
</div>
</div>
</section>

@ -0,0 +1,42 @@
import {tns} from "tiny-slider/src/tiny-slider";
var brandSlider ;
document.addEventListener('DOMContentLoaded', () => {
document.querySelectorAll('#brands-slider')?.forEach(function (el) {
if (el.classList.contains('.tns-slider')){
console.log('ignore');
return 'ignore';
}
brandSlider = tns({
container: el,
items: 3,
autoplay: true,
autoplayButton: false,
// nextButton: false,
autoplayHoverPause: true,
mouseDrag: true,
gutter: 20,
slideBy: 1,
controlsPosition: "bottom",
navPosition: "bottom",
controls: false,
responsive:{
560:{
items: 1,
},
768:{
items: 2,
},
1000:{
items: 3,
},
1400:{
items: 4,
},
}
// speed:10000,
});
});
});

@ -0,0 +1,10 @@
{
"name": "CategoriesFavImageLinks",
"version": "1.0",
"author": "xStack",
"email": "xshop@xstack.ir",
"license": "GPL-3.0-or-later",
"url": "https:\/\/xstack.ir",
"author_url": "https:\/\/4xmen.ir",
"packages": []
}

@ -0,0 +1,46 @@
<?php
namespace Resources\Views\Segments;
use App\Models\Category;
use App\Models\Group;
use App\Models\Part;
use App\Models\Setting;
class CategoriesFavImageLinks
{
public static function onAdd(Part $part = null)
{
$setting = new Setting();
$setting->section = 'theme';
$setting->key = $part->area->name . '_' . $part->part.'_title';
$setting->value = 'Brands';
$setting->size = 6;
$setting->type = 'TEXT';
// $setting->data = json_encode(['xmin' => 2, 'xmax' => 90]);
$setting->title = $part->area->name . ' ' . $part->part. ' title';
$setting->save();
$setting = new Setting();
$setting->section = 'theme';
$setting->key = $part->area->name . '_' . $part->part.'_category';
$setting->value = Category::first()->id;
$setting->size = 6;
$setting->type = 'CATEGORY';
// $setting->data = json_encode(['xmin' => 2, 'xmax' => 90]);
$setting->title = $part->area->name . ' ' . $part->part. ' group';
$setting->save();
}
public static function onRemove(Part $part = null)
{
Setting::where('key',$part->area->name . '_' . $part->part.'_title')->first()?->delete();
Setting::where('key',$part->area->name . '_' . $part->part.'_category')->first()?->delete();
}
public static function onMount(Part $part = null)
{
return $part;
}
}

@ -0,0 +1,45 @@
#CategoriesFavImageLinks {
padding: 4rem 0;
h1{
text-align: center;
font-weight: 200;
font-size: 28px;
margin-bottom: 2rem;
}
#brands-slider{
.item{
text-align: center;
}
}
img{
height: 64px;
}
.tns-nav,button{
display: inline-block;
}
[data-action="stop"], [data-action="start"]{
display: none;
}
.tns-nav{
margin-top: 2rem;
display: block;
text-align: center;
button{
opacity: .4;
margin: .4rem;
height: 12px;
width: 12px;
border-radius: 50%;
background: var(--xshop-primary);
border: 0;
transition: 400ms;
&.tns-nav-active{
opacity: 1;
}
}
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

@ -62,7 +62,7 @@ document.addEventListener('DOMContentLoaded', () => {
console.log('ignore');
return 'ignore';
}
treeSliderX = tns({
treeSliderY = tns({
container: el,
items: 1,
autoplay: true,

Loading…
Cancel
Save