added index image post theme part

pull/49/head
A1Gard 4 months ago
parent a05298b15c
commit 83daefba26

@ -805,10 +805,10 @@ function getMenuBySetting($key)
* @param $limit * @param $limit
* @return \App\Models\Post[]|\Illuminate\Database\Eloquent\Collection|\LaravelIdea\Helper\App\Models\_IH_Post_C * @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() 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 * @param $limit
* @return \App\Models\Post[]|\Illuminate\Database\Eloquent\Collection|\LaravelIdea\Helper\App\Models\_IH_Post_C * @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() 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();
} }
/** /**

@ -24,7 +24,7 @@ class NoLinkImage
$setting = new Setting(); $setting = new Setting();
$setting->section = 'theme'; $setting->section = 'theme';
$setting->key = $part->area->name . '_' . $part->part.'_dark'; $setting->key = $part->area->name . '_' . $part->part.'_dark';
$setting->value = Group::first()->id; $setting->value = 0;
$setting->size = 6; $setting->size = 6;
$setting->type = 'CHECKBOX'; $setting->type = 'CHECKBOX';
// $setting->data = json_encode(['xmin' => 2, 'xmax' => 90]); // $setting->data = json_encode(['xmin' => 2, 'xmax' => 90]);
@ -34,6 +34,8 @@ class NoLinkImage
public static function onRemove(Part $part = null) 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) public static function onMount(Part $part = null)
{ {

@ -0,0 +1,36 @@
<section class='PostIndexImage'>
<div class="{{gfx()['container']}}">
<h1>
<a href="{{getGroupBySetting($data->area->name.'_'.$data->part.'_group')->webUrl()}}">
{{getGroupBySetting($data->area->name.'_'.$data->part.'_group')->name}}
</a>
</h1>
<p class="text-muted">
{{getGroupBySetting($data->area->name.'_'.$data->part.'_group')->description}}
</p>
<div class="row">
@foreach( getGroupPostsBySetting($data->area->name.'_'.$data->part.'_group',4) as $post )
<div class="col-lg-3 col-md-6">
<div class="post-img-index">
<img src="{{$post->imgUrl()}}" alt="{{$post->title}}" class="img-fluid">
<h3>
{{$post->title}}
</h3>
<p class="text-muted">
{{$post->subtitle}}
</p>
<a href="{{$post->webUrl()}}">
{{__("Read more")}}
</a>
</div>
</div>
@endforeach
</div>
<div class="py-5 text-center">
<a href="{{getGroupBySetting($data->area->name.'_'.$data->part.'_group')->webUrl()}}" class="btn btn-outline-primary">
{{getSetting($data->area->name.'_'.$data->part.'_btn')}}
</a>
</div>
</div>
</section>

@ -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": []
}

@ -0,0 +1,43 @@
<?php
namespace Resources\Views\Segments;
use App\Models\Group;
use App\Models\Part;
use App\Models\Setting;
class PostIndexImage
{
public static function onAdd(Part $part = null)
{
$setting = new Setting();
$setting->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;
}
}

@ -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;
}
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 236 KiB

Loading…
Cancel
Save