added compare product theme part

fixed bugs & improved ui/ux in product fullMeta
added compare route
improved select filter category client
pull/49/head
A1Gard 5 months ago
parent 5956918dad
commit 7051a0e40b

@ -206,6 +206,8 @@ class ClientController extends Controller
->where('data', 'LIKE', '%"'.$prop->name.'":"' . $request->meta[$prop->name] . '"%')
->pluck('product_id')->toArray();
$id = array_merge($id,$query->whereMeta($prop->name, $request->input('meta')[$prop->name])->pluck('id')->toArray());
$id = array_unique($id);
$query->whereIn('id', $id);
}else{
$query->whereMeta($prop->name, $request->input('meta')[$prop->name]);
@ -347,4 +349,17 @@ class ClientController extends Controller
return redirect()->back()->with(['message' => $message]);
}
}
public function compare()
{
$area = 'compare';
$title = __("Compare products");
$subtitle = '';
$ids = json_decode(\Cookie::get('compares'), true);
$products = Product::whereIn('id',$ids)->where('status',1)->get();
return view('client.default-list', compact('area', 'products', 'title', 'subtitle'));
}
}

@ -232,13 +232,18 @@ class Product extends Model implements HasMedia
$result[$key]['human_value'] = "<div style='background: $value' class='color-bullet'> &nbsp; </div>";
break;
case 'checkbox':
$result[$key]['human_value'] = $value ? '✅' : '❌';
$result[$key]['human_value'] = $value ? '<i class="ri-checkbox-circle-line"></i>' : '<i class="ri-close-circle-line"></i>';
break;
case 'multi':
case 'select':
case 'singlemulti':
if (!is_array($value)) {
$result[$key]['human_value'] = $result[$key]['data']->datas[$value];
if (isset( $result[$key]['data']->datas[$value])){
$result[$key]['human_value'] =
$result[$key]['data']->datas[$value];
}else{
$result[$key]['human_value'] = '-';
}
} else {
$result[$key]['human_value'] = '';
foreach ($value as $k => $v) {
@ -249,10 +254,13 @@ class Product extends Model implements HasMedia
break;
default:
if (is_array($value)) {
$result[$key]['human_value'] = implode(', ', $value);
$result[$key]['human_value'] = '<span class="meta-tag">'.implode('</span> <span class="meta-tag">', $value).'</span>';
} else {
$result[$key]['human_value'] = $value;
if ($value == '' || $value == null) {
$result[$key]['human_value'] = '-';
}else{
$result[$key]['human_value'] = $value;
}
}
}

@ -0,0 +1,47 @@
<section class='CompareProducts content'>
<div class="{{gfx()['container']}}">
<h1>
{{$title}}
</h1>
<div class="row">
@foreach($products as $product)
<div class="col-md">
<div class="compare">
<div class="top">
<img src="{{$product->originalImageUrl()}}" alt="">
<h2>
{{$product->name}}
</h2>
</div>
<ul>
<li>
<span>
{{__("Price")}}
</span>
<b>
{{$product->getPrice()}}
</b>
</li>
@foreach($product->fullMeta() as $meta)
<li>
<span>
{{$meta['data']->label}}
</span>
<b class="float-end">
{!! $meta['human_value'] !!}
</b>
</li>
@endforeach
</ul>
<div class="p-2">
<a href="{{ route('client.product-card-toggle',$product->slug) }}" class="btn btn-outline-primary w-100 add-to-card">
<i class="ri-shopping-bag-3-line"></i>
{{__("Add to card")}}
</a>
</div>
</div>
</div>
@endforeach
</div>
</div>
</section>

@ -0,0 +1,10 @@
{
"name": "CompareProducts",
"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,21 @@
<?php
namespace Resources\Views\Segments;
use App\Models\Part;
class CompareProducts
{
public static function onAdd(Part $part = null)
{
}
public static function onRemove(Part $part = null)
{
}
public static function onMount(Part $part = null)
{
return $part;
}
}

@ -0,0 +1,46 @@
.CompareProducts {
padding: 1rem 0;
h1{
font-size: 25px;
font-weight: 300;
text-align: center;
}
.compare{
background: #ffffff;
border-radius: var(--xshop-border-radius);
h2{
font-weight: 300;
text-align: center;
background: var(--xshop-primary);
color: var(--xshop-diff);
padding: .5rem;
margin-bottom: 0;
}
img{
height: 30vh;
width: 100%;
object-fit: cover;
}
.top{
border-radius: var(--xshop-border-radius);
overflow: hidden;
}
ul{
padding-top: 1rem;
}
li{
list-style: none;
padding: 7px;
.meta-tag{
background: #00000011 ;
padding: 3px;
border-radius: var(--xshop-border-radius);
}
}
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 271 KiB

@ -361,6 +361,7 @@ Route::middleware([\App\Http\Middleware\VisitorCounter::class])
// index
Route::get('/', [\App\Http\Controllers\ClientController::class,'welcome'])->name('welcome');
Route::get('/posts', [\App\Http\Controllers\ClientController::class,'posts'])->name('posts');
Route::get('/compare', [\App\Http\Controllers\ClientController::class,'compare'])->name('compare');
Route::get('/galleries', [\App\Http\Controllers\ClientController::class,'galleries'])->name('galleries');
Route::get('/products', [\App\Http\Controllers\ClientController::class,'products'])->name('products');
Route::get('/tag/{post}', [\App\Http\Controllers\ClientController::class,'tag'])->name('tag'); // wip

Loading…
Cancel
Save