diff --git a/app/Helpers/Helper.php b/app/Helpers/Helper.php index 3563f0f..b4b9fc5 100644 --- a/app/Helpers/Helper.php +++ b/app/Helpers/Helper.php @@ -805,10 +805,10 @@ function getMenuBySetting($key) * @param $limit * @return \App\Models\Post[]|\Illuminate\Database\Eloquent\Collection|\LaravelIdea\Helper\App\Models\_IH_Post_C */ -function getGroupPostsBySetting($key, $limit = 10) +function getGroupPostsBySetting($key, $limit = 10, $order = 'id', $dir = "DESC") { return Group::where('id', getSetting($key) ?? 1)->first() - ->posts()->where('status', 1)->limit($limit)->get(); + ->posts()->where('status', 1)->orderBy($order, $dir)->limit($limit)->get(); } /** @@ -817,10 +817,10 @@ function getGroupPostsBySetting($key, $limit = 10) * @param $limit * @return \App\Models\Post[]|\Illuminate\Database\Eloquent\Collection|\LaravelIdea\Helper\App\Models\_IH_Post_C */ -function getCategoryProductBySetting($key, $limit = 10) +function getCategoryProductBySetting($key, $limit = 10, $order = 'id', $dir = "DESC") { return Category::where('id', getSetting($key) ?? 1)->first() - ->products()->where('status', 1)->limit($limit)->get(); + ->products()->where('status', 1)->orderBy($order, $dir)->limit($limit)->get(); } /** diff --git a/resources/views/segments/posts/NoLinkImage/NoLinkImage.php b/resources/views/segments/posts/NoLinkImage/NoLinkImage.php index beb40a0..0733f8b 100644 --- a/resources/views/segments/posts/NoLinkImage/NoLinkImage.php +++ b/resources/views/segments/posts/NoLinkImage/NoLinkImage.php @@ -24,7 +24,7 @@ class NoLinkImage $setting = new Setting(); $setting->section = 'theme'; $setting->key = $part->area->name . '_' . $part->part.'_dark'; - $setting->value = Group::first()->id; + $setting->value = 0; $setting->size = 6; $setting->type = 'CHECKBOX'; // $setting->data = json_encode(['xmin' => 2, 'xmax' => 90]); @@ -34,6 +34,8 @@ class NoLinkImage public static function onRemove(Part $part = null) { + Setting::where('key',$part->area->name . '_' . $part->part.'_group')->first()?->delete(); + Setting::where('key',$part->area->name . '_' . $part->part.'_dark')->first()?->delete(); } public static function onMount(Part $part = null) { diff --git a/resources/views/segments/posts/PostIndexImage/PostIndexImage.blade.php b/resources/views/segments/posts/PostIndexImage/PostIndexImage.blade.php new file mode 100644 index 0000000..20979c5 --- /dev/null +++ b/resources/views/segments/posts/PostIndexImage/PostIndexImage.blade.php @@ -0,0 +1,36 @@ +
+
+

+ + {{getGroupBySetting($data->area->name.'_'.$data->part.'_group')->name}} + +

+

+ {{getGroupBySetting($data->area->name.'_'.$data->part.'_group')->description}} +

+
+ @foreach( getGroupPostsBySetting($data->area->name.'_'.$data->part.'_group',4) as $post ) +
+
+ {{$post->title}} +

+ {{$post->title}} +

+

+ {{$post->subtitle}} +

+ + {{__("Read more")}} + +
+
+ + @endforeach +
+ +
+
diff --git a/resources/views/segments/posts/PostIndexImage/PostIndexImage.js b/resources/views/segments/posts/PostIndexImage/PostIndexImage.js new file mode 100644 index 0000000..e69de29 diff --git a/resources/views/segments/posts/PostIndexImage/PostIndexImage.json b/resources/views/segments/posts/PostIndexImage/PostIndexImage.json new file mode 100644 index 0000000..20c3ada --- /dev/null +++ b/resources/views/segments/posts/PostIndexImage/PostIndexImage.json @@ -0,0 +1,10 @@ +{ + "name": "PostIndexImage", + "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": [] +} \ No newline at end of file diff --git a/resources/views/segments/posts/PostIndexImage/PostIndexImage.php b/resources/views/segments/posts/PostIndexImage/PostIndexImage.php new file mode 100644 index 0000000..4c33571 --- /dev/null +++ b/resources/views/segments/posts/PostIndexImage/PostIndexImage.php @@ -0,0 +1,43 @@ +section = 'theme'; + $setting->key = $part->area->name . '_' . $part->part.'_group'; + $setting->value = Group::first()->id; + $setting->size = 6; + $setting->type = 'GROUP'; +// $setting->data = json_encode(['xmin' => 2, 'xmax' => 90]); + $setting->title = $part->area->name . ' ' . $part->part. ' group'; + $setting->save(); + + $setting = new Setting(); + $setting->section = 'theme'; + $setting->key = $part->area->name . '_' . $part->part.'_btn'; + $setting->value = __("Find more"); + $setting->size = 6; + $setting->type = 'TEXT'; +// $setting->data = json_encode(['xmin' => 2, 'xmax' => 90]); + $setting->title = $part->area->name . ' ' . $part->part. ' button text'; + $setting->save(); + } + public static function onRemove(Part $part = null) + { + Setting::where('key',$part->area->name . '_' . $part->part.'_group')->first()?->delete(); + Setting::where('key',$part->area->name . '_' . $part->part.'_btn')->first()?->delete(); + } + public static function onMount(Part $part = null) + { + return $part; + } +} diff --git a/resources/views/segments/posts/PostIndexImage/PostIndexImage.scss b/resources/views/segments/posts/PostIndexImage/PostIndexImage.scss new file mode 100644 index 0000000..bcb103b --- /dev/null +++ b/resources/views/segments/posts/PostIndexImage/PostIndexImage.scss @@ -0,0 +1,48 @@ +.PostIndexImage { + // scss + h1{ + font-size: 30px; + text-align: center; + position: relative; + padding: 1rem; + &:before{ + content: ' '; + position: absolute; + inset-inline-start: 47%; + inset-inline-end: 47%; + top: 0; + height: 4px; + background: var(--xshop-primary); + } + } + + .post-img-index{ + background: #ffffff33; + box-shadow: var(--xshop-shadow); + border-radius: var(--xshop-border-radius); + padding: 1rem; + + h3{ + font-size: 22px; + padding: 1rem 0; + height: 3.5em; + position: relative; + overflow: hidden; + + &:before{ + content: ' '; + position: absolute; + inset-inline-end: 5%; + width: 15%; + bottom: 0; + height: 2px; + background: var(--xshop-primary); + } + } + img{ + width: 100%; + height: 15vh; + object-fit: cover; + } + } +} diff --git a/resources/views/segments/posts/PostIndexImage/screenshot.png b/resources/views/segments/posts/PostIndexImage/screenshot.png new file mode 100644 index 0000000..03b64cc Binary files /dev/null and b/resources/views/segments/posts/PostIndexImage/screenshot.png differ