diff --git a/app/Console/Commands/makePart.php b/app/Console/Commands/makePart.php index 456acd6..0e118c3 100644 --- a/app/Console/Commands/makePart.php +++ b/app/Console/Commands/makePart.php @@ -77,7 +77,7 @@ class makePart extends Command } DOC; - file_put_contents($folderPath . '/' . $part . '.blade.php', "
"); + file_put_contents($folderPath . '/' . $part . '.blade.php', str_replace('THEME_PART_NAME',$part,'
')); file_put_contents($folderPath . '/' . $part . '.js', ''); file_put_contents($folderPath . '/' . $part . '.json', json_encode($detail,JSON_PRETTY_PRINT)); file_put_contents($folderPath . '/' . ucfirst($part) . '.php', $handler); diff --git a/app/Helpers/Helper.php b/app/Helpers/Helper.php index 5ee91fb..849f0f3 100644 --- a/app/Helpers/Helper.php +++ b/app/Helpers/Helper.php @@ -6,6 +6,7 @@ use App\Models\Group; use App\Models\Category; use App\Models\Area; use App\Models\Part; +use App\Models\Post; use App\Models\Menu; use App\Models\Product; use App\Models\Rate; @@ -902,6 +903,23 @@ function getProductsQueryBySetting($key, $limit = 10) } return $q->orderBy($data[1], $data[2])->limit($limit)->get(); } +/** + * get posts by setting key + * @param $key + * @param integer $limit + * @return \App\Models\Post[]|\Illuminate\Database\Eloquent\Collection|\LaravelIdea\Helper\App\Models\_IH_Post_C + */ +function getPostsQueryBySetting($key, $limit = 10) +{ + $data = explode(',', getSetting($key) ?? '1,id,DESC'); + if ($data[0] == 0) { + $q = Post::where('status', 1); + }else{ + $q = Group::where('id', $data[0])->first() + ->posts()->where('status', 1); + } + return $q->orderBy($data[1], $data[2])->limit($limit)->get(); +} /** * get group's posts by setting key diff --git a/resources/views/components/setting-field.blade.php b/resources/views/components/setting-field.blade.php index 12cb078..f849cc3 100644 --- a/resources/views/components/setting-field.blade.php +++ b/resources/views/components/setting-field.blade.php @@ -151,7 +151,7 @@ key) :err="true" @enderror - :items='@json($groups)' + :items='@json($groupz)' title-field="name" value-field="id" xlang="{{config('app.locale')}}" diff --git a/resources/views/segments/posts/PostsSlider/PostsSlider.blade.php b/resources/views/segments/posts/PostsSlider/PostsSlider.blade.php index 66783f6..74c000e 100644 --- a/resources/views/segments/posts/PostsSlider/PostsSlider.blade.php +++ b/resources/views/segments/posts/PostsSlider/PostsSlider.blade.php @@ -5,11 +5,13 @@ +
- @foreach( getGroupPostsBySetting($data->area_name.'_'.$data->part.'_group',10) as $post ) + + @foreach( getPostsQueryBySetting($data->area_name.'_'.$data->part.'_query',10) as $post )
@@ -23,5 +25,12 @@
@endforeach
+ +
+
+ +
+
+
diff --git a/resources/views/segments/posts/PostsSlider/PostsSlider.js b/resources/views/segments/posts/PostsSlider/PostsSlider.js index 19691d6..73eacfe 100644 --- a/resources/views/segments/posts/PostsSlider/PostsSlider.js +++ b/resources/views/segments/posts/PostsSlider/PostsSlider.js @@ -1,10 +1,10 @@ import {tns} from "tiny-slider/src/tiny-slider"; -var postsSlider ; +var postsSlider; document.addEventListener('DOMContentLoaded', () => { document.querySelectorAll('#posts-slider')?.forEach(function (el) { - if (el.classList.contains('.tns-slider')){ + if (el.classList.contains('.tns-slider')) { console.log('ignore'); return 'ignore'; } @@ -17,20 +17,24 @@ document.addEventListener('DOMContentLoaded', () => { mouseDrag: true, autoplayTimeout: 5000, gutter: 10, - responsive:{ - 560:{ + responsive: { + 560: { items: 2, edgePadding: 30, }, - 768:{ - items: 4, + 768: { + items: 3, edgePadding: 40, }, - 1000:{ - items: 5, + 1000: { + items: 4, edgePadding: 50, }, - 1400:{ + 1400: { + items: 5, + edgePadding: 60, + }, + 1700: { items: 6, edgePadding: 60, }, @@ -40,4 +44,19 @@ document.addEventListener('DOMContentLoaded', () => { }); }); + document.querySelector('#pst-nxt')?.addEventListener('click',function () { + if (document.documentElement.getAttribute('dir') === 'rtl'){ + postsSlider.goTo('prev'); + }else{ + postsSlider.goTo('next'); + } + }); + document.querySelector('#pst-prv')?.addEventListener('click',function () { + if (document.documentElement.getAttribute('dir') !== 'rtl'){ + postsSlider.goTo('prev'); + }else{ + postsSlider.goTo('next'); + } + }); + }); diff --git a/resources/views/segments/posts/PostsSlider/PostsSlider.php b/resources/views/segments/posts/PostsSlider/PostsSlider.php index 7b9d165..be518db 100644 --- a/resources/views/segments/posts/PostsSlider/PostsSlider.php +++ b/resources/views/segments/posts/PostsSlider/PostsSlider.php @@ -10,27 +10,30 @@ class PostsSlider { public static function onAdd(Part $part = null) { + $setting = new Setting(); $setting->section = 'theme'; - $setting->key = $part->area_name . '_' . $part->part.'_title'; - $setting->value = 'Lorem ipsum dolor sit amet'; - $setting->type = 'TEXT'; - $setting->size = 12; - $setting->title = $part->area_name . ' ' . $part->part .' title'; + $setting->key = $part->area_name . '_' . $part->part.'_query'; + $setting->value = Group::first()->id.',id,DESC'; + $setting->size = 6; + $setting->type = 'POST_QUERY'; + $setting->title = $part->area_name . ' ' . $part->part. ' query'; $setting->save(); + $setting = new Setting(); $setting->section = 'theme'; - $setting->key = $part->area_name . '_' . $part->part.'_group'; - $setting->value = Group::first()->id; + $setting->key = $part->area_name . '_' . $part->part.'_title'; + $setting->value = 'Lorem ipsum dolor sit amet'; + $setting->type = 'TEXT'; $setting->size = 6; - $setting->type = 'GROUP'; -// $setting->data = json_encode(['xmin' => 2, 'xmax' => 90]); - $setting->title = $part->area_name . ' ' . $part->part. ' group'; + $setting->title = $part->area_name . ' ' . $part->part .' title'; $setting->save(); + + $setting = new Setting(); $setting->section = 'theme'; $setting->key = $part->area_name . '_' . $part->part.'_color'; diff --git a/resources/views/segments/posts/PostsSlider/PostsSlider.scss b/resources/views/segments/posts/PostsSlider/PostsSlider.scss index d560187..44c7d50 100644 --- a/resources/views/segments/posts/PostsSlider/PostsSlider.scss +++ b/resources/views/segments/posts/PostsSlider/PostsSlider.scss @@ -3,6 +3,7 @@ padding: 3rem 0; background: var(--post-slider-color); color: var(--xshop-diff); + position: relative; h1{ font-size: 30px; @@ -31,10 +32,13 @@ background: linear-gradient(-90deg, var(--post-slider-color) 20%, rgba(0,0,0,0) 100%); } + + } .post-slider{ border-radius: var(--xshop-border-radius); position: relative; + margin-bottom: 1rem; img{ width: 100%; height: 35vh; @@ -64,4 +68,48 @@ } } + + .tns-nav{ + position: absolute; + display: flex !important; + width: 200px; + left: 50%; + height: 50px; + bottom: -2rem; + transform: translateX(-50%); + + align-items: center; + justify-content: center; + button{ + display: inline-block; + margin: 7px; + width: 10px; + height: 10px; + border-radius: var(--xshop-border-radius); + background: #ffffff; + border: 0; + } + + .tns-nav-active{ + + background: var(--xshop-secondary); + } + } + + .sld-btn{ + position: absolute; + top: 47%; + cursor: pointer; + z-index: 55; + i{ + font-size: 35px; + } + } + + #pst-nxt{ + right: 45px; + } + #pst-prv{ + left: 45px; + } } diff --git a/resources/views/segments/products/LatestProducts/LatestProducts.blade.php b/resources/views/segments/products/LatestProducts/LatestProducts.blade.php index 65d1215..aded2df 100644 --- a/resources/views/segments/products/LatestProducts/LatestProducts.blade.php +++ b/resources/views/segments/products/LatestProducts/LatestProducts.blade.php @@ -6,7 +6,9 @@
@foreach(\App\Models\Product::where('status',1)->orderByDesc('id')->limit(4)->get() as $product)
- @include(\App\Models\Area::where('name','product-grid')->first()->defPart(),compact('product')) +
+ @include(\App\Models\Area::where('name','product-grid')->first()->defPart(),compact('product')) +
@endforeach
diff --git a/resources/views/segments/products/ProductsSlider/ProductsSlider.blade.php b/resources/views/segments/products/ProductsSlider/ProductsSlider.blade.php index d91a7d5..ac99185 100644 --- a/resources/views/segments/products/ProductsSlider/ProductsSlider.blade.php +++ b/resources/views/segments/products/ProductsSlider/ProductsSlider.blade.php @@ -1,4 +1,4 @@ -
+
part}}' >

{{getSetting($part->area_name . '_' . $part->part.'_title')}}