added some feature for theme and setting

fixed some bugs
optimized make part
pull/44/head
A1Gard 4 months ago
parent feb51a2781
commit 861b6fd5a0

@ -72,12 +72,12 @@ class makePart extends Command
$handler = str_replace('Handle',ucfirst($part), $handler); $handler = str_replace('Handle',ucfirst($part), $handler);
$scss = <<<DOC $scss = <<<DOC
#$part { .$part {
// scss // scss
} }
DOC; DOC;
file_put_contents($folderPath . '/' . $part . '.blade.php', "<div id='{$part}'></div>"); file_put_contents($folderPath . '/' . $part . '.blade.php', "<section class='{$part}'></section>");
file_put_contents($folderPath . '/' . $part . '.js', ''); file_put_contents($folderPath . '/' . $part . '.js', '');
file_put_contents($folderPath . '/' . $part . '.json', json_encode($detail,JSON_PRETTY_PRINT)); file_put_contents($folderPath . '/' . $part . '.json', json_encode($detail,JSON_PRETTY_PRINT));
file_put_contents($folderPath . '/' . ucfirst($part) . '.php', $handler); file_put_contents($folderPath . '/' . ucfirst($part) . '.php', $handler);

@ -3,6 +3,7 @@
use App\Helpers; use App\Helpers;
use App\Models\Setting; use App\Models\Setting;
use App\Models\Group; use App\Models\Group;
use App\Models\Category;
use App\Models\Area; use App\Models\Area;
use App\Models\Part; use App\Models\Part;
use Illuminate\Support\Facades\Route; use Illuminate\Support\Facades\Route;
@ -776,3 +777,15 @@ function getGroupPostsBySetting($key, $limit = 10)
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)->limit($limit)->get();
} }
/**
* get group's posts by setting key
* @param $key
* @param $limit
* @return \App\Models\Post[]|\Illuminate\Database\Eloquent\Collection|\LaravelIdea\Helper\App\Models\_IH_Post_C
*/
function getCategoryProductBySetting($key, $limit = 10)
{
return Category::where('id', getSetting($key) ?? 1)->first()
->products()->where('status', 1)->limit($limit)->get();
}

@ -71,7 +71,9 @@ class AreaController extends Controller
$part->save(); $part->save();
} }
} }
Part::whereIn('id', json_decode($request->input('removed')))->delete(); foreach ( json_decode($request->input('removed')) as $id){
Part::where('id',$id)->first()->delete();
}
\Artisan::call('client'); \Artisan::call('client');
logAdmin(__METHOD__,__CLASS__,$area->id); logAdmin(__METHOD__,__CLASS__,$area->id);

@ -83,7 +83,7 @@ class SettingController extends Controller
$files = $request->allFiles(); $files = $request->allFiles();
if (isset($files['file'])) { if (isset($files['file'])) {
foreach ($files['file'] as $index => $file) { foreach ($files['file'] as $index => $file) {
if ($file->extension() == 'mp4' || $file->extension() == 'mp3'){ if ($file->guessExtension() == 'mp4' || $file->guessExtension() == 'mp3'){
$file->move(public_path('upload/media/'), str_replace('_','.',$index) );//store('/images/'.,['disk' => 'public']); $file->move(public_path('upload/media/'), str_replace('_','.',$index) );//store('/images/'.,['disk' => 'public']);
}else{ }else{
$file->move(public_path('upload/images/'), str_replace('_','.',$index) );//store('/images/'.,['disk' => 'public']); $file->move(public_path('upload/images/'), str_replace('_','.',$index) );//store('/images/'.,['disk' => 'public']);

@ -75,4 +75,8 @@ class Category extends Model
return route(''); return route('');
} }
public function products(){
return $this->belongsToMany(Product::class);
}
} }

@ -24,17 +24,19 @@ class Product extends Model implements HasMedia
'qidz' => 'array' 'qidz' => 'array'
]; ];
public function attachs(){ public function attachs()
return $this->morphMany(Attachment::class,'attachable'); {
return $this->morphMany(Attachment::class, 'attachable');
} }
protected $guarded = []; protected $guarded = [];
public function getQzAttribute(){ public function getQzAttribute()
{
$result = []; $result = [];
foreach ($this->quantities as $q) { foreach ($this->quantities as $q) {
if ($q->count > 0){ if ($q->count > 0) {
$q->data = json_decode($q->data); $q->data = json_decode($q->data);
$result[] = $q; $result[] = $q;
} }
@ -42,13 +44,15 @@ class Product extends Model implements HasMedia
return $result; return $result;
} }
public function getQidzAttribute(){
public function getQidzAttribute()
{
return $this->quantities()->pluck('id')->toArray(); return $this->quantities()->pluck('id')->toArray();
} }
public static $stock_status = ['IN_STOCK', 'OUT_STOCK', 'BACK_ORDER']; public static $stock_status = ['IN_STOCK', 'OUT_STOCK', 'BACK_ORDER'];
public $translatable = ['name', 'excerpt', 'description','table']; public $translatable = ['name', 'excerpt', 'description', 'table'];
public function registerMediaConversions(?Media $media = null): void public function registerMediaConversions(?Media $media = null): void
{ {
@ -73,7 +77,7 @@ class Product extends Model implements HasMedia
->nonQueued() ->nonQueued()
->format(getSetting('optimize')); ->format(getSetting('optimize'));
if (getSetting('watermark')){ if (getSetting('watermark')) {
$mc->watermark(public_path('upload/images/logo.png'), $mc->watermark(public_path('upload/images/logo.png'),
AlignPosition::BottomLeft, 5, 5, Unit::Percent, AlignPosition::BottomLeft, 5, 5, Unit::Percent,
config('app.media.watermark_size'), Unit::Percent, config('app.media.watermark_size'), Unit::Percent,
@ -86,6 +90,12 @@ class Product extends Model implements HasMedia
config('app.media.watermark_size'), Unit::Percent, Fit::Contain, config('app.media.watermark_size'), Unit::Percent, Fit::Contain,
config('app.media.watermark_opacity')); config('app.media.watermark_opacity'));
} }
$this->addMediaConversion('product-optimized')
->optimize()
->sharpen(10)
->nonQueued()
->format('webp');
} }
@ -151,35 +161,52 @@ class Product extends Model implements HasMedia
} }
} }
public function imgUrl(){ public function imgUrl()
{
if ($this->getMedia()->count() > 0) { if ($this->getMedia()->count() > 0) {
return $this->getMedia()[$this->image_index]->getUrl('product-image'); return $this->getMedia()[$this->image_index]->getUrl('product-image');
} else { } else {
return asset('assets/upload/logo.svg'); return asset('assets/upload/logo.svg');
} }
} }
public function orginalImageUrl(){
public function originalImageUrl()
{
if ($this->getMedia()->count() > 0) { if ($this->getMedia()->count() > 0) {
return $this->getMedia()[$this->image_index]->getUrl(); return $this->getMedia()[$this->image_index]->getUrl();
} else { } else {
return asset('assets/upload/logo.svg'); return asset('assets/upload/logo.svg');
} }
} }
public function imgUrl2(){ public function originalOptimizedImageUrl()
{
if ($this->getMedia()->count() > 0) {
return $this->getMedia()[$this->image_index]->getUrl('product-optimized');
} else {
return asset('assets/upload/logo.svg');
}
}
public function imgUrl2()
{
if ($this->getMedia()->count() > 0 && isset($this->getMedia()[1])) { if ($this->getMedia()->count() > 0 && isset($this->getMedia()[1])) {
return $this->getMedia()[1]->getUrl('product-image'); return $this->getMedia()[1]->getUrl('product-image');
} else { } else {
return asset('assets/upload/logo.svg'); return asset('assets/upload/logo.svg');
} }
} }
public function thumbUrl(){
public function thumbUrl()
{
if ($this->getMedia()->count() > 0) { if ($this->getMedia()->count() > 0) {
return $this->getMedia()[$this->image_index]->getUrl('product-thumb'); return $this->getMedia()[$this->image_index]->getUrl('product-thumb');
} else { } else {
return asset('assets/upload/logo.svg'); return asset('assets/upload/logo.svg');
} }
} }
public function thumbUrl2(){
public function thumbUrl2()
{
if ($this->getMedia()->count() > 0 && isset($this->getMedia()[1])) { if ($this->getMedia()->count() > 0 && isset($this->getMedia()[1])) {
return $this->getMedia()[1]->getUrl('product-thumb'); return $this->getMedia()[1]->getUrl('product-thumb');
} else { } else {
@ -188,7 +215,59 @@ class Product extends Model implements HasMedia
} }
public function webUrl(){ public function fullMeta($limit = 99)
{
$metas = $this->getAllMeta()->toArray();
$result = [];
$i = 0;
foreach ($metas as $key => $value) {
$result[$key] = [
'value' => $value,
'data' => Prop::where('name', $key)->first(),
];
switch ($result[$key]['data']['type']) {
case 'color':
$result[$key]['human_value'] = "<div style='background: $value' class='color-bullet'> &nbsp; </div>";
break;
case 'checkbox':
$result[$key]['human_value'] = $value ? '✅' : '❌';
break;
case 'multi':
case 'select':
case 'singlemulti':
if (!is_array($value)) {
$result[$key]['human_value'] = $result[$key]['data']->datas[$value];
} else {
$result[$key]['human_value'] = '';
foreach ($value as $k => $v) {
$result[$key]['human_value'] = $result[$key]['data']->datas[$v].', ';
}
$result[$key]['human_value'] = trim($result[$key]['human_value'],' ,');
}
break;
default:
if (is_array($value)) {
$result[$key]['human_value'] = implode(', ', $value);
} else {
$result[$key]['human_value'] = $value;
}
}
$result[$key]['human_value'] .= ' ' . $result[$key]['data']['unit'];
}
usort($result, function ($a, $b) {
return $a['data']['sort'] - $b['data']['sort'];
});
$result = array_slice($result, 0, $limit);
return $result;
}
public function webUrl()
{
return '#';// WIP return '#';// WIP
return route(''); return route('');
} }

@ -16,7 +16,8 @@ class Prop extends Model
protected $casts = [ protected $casts = [
'dataz', 'dataz',
'optionz' 'optionz',
'datas'
]; ];
public static $prop_types = ['text', 'number', 'checkbox', 'color', 'select', 'multi', 'singlemulti']; public static $prop_types = ['text', 'number', 'checkbox', 'color', 'select', 'multi', 'singlemulti'];
@ -35,6 +36,15 @@ class Prop extends Model
return $result; return $result;
} }
public function getDatasAttribute()
{
$result = [];
foreach (json_decode($this->options) as $item) {
$result[$item->value] = $item->title;
}
return $result;
}
public function getOptionzAttribute() public function getOptionzAttribute()
{ {

@ -28,7 +28,7 @@ class AreaSeeder extends Seeder
'valid_segments' => json_encode( 'valid_segments' => json_encode(
["top","slider","header","footer","menu", ["top","slider","header","footer","menu",
"parallax","other","posts","products","attachments" "parallax","other","posts","products","attachments"
,"groups","categories"] ,"groups","categories","category","group"]
), ),
'max' => 10, 'max' => 10,
'icon' => 'ri-layout-top-2-line', 'icon' => 'ri-layout-top-2-line',

@ -11,10 +11,10 @@
</span> </span>
</div> </div>
<div class="part-body"> <div class="part-body">
<div class="row"> <div class="rw">
<template v-for="(valid,i) in valids"> <template v-for="(valid,i) in valids">
<div @click="changePart(p,valid.segment,valid.part)" <div @click="changePart(p,valid.segment,valid.part)"
:class="`col-md-3 `+(valid.data.name == part.part?'selected-part':'can-select')"> :class="``+(valid.data.name == part.part?'selected-part':'can-select')">
<img class="img-fluid mt-2" :src="imageLink+'/'+valid.segment+'/'+valid.part" <img class="img-fluid mt-2" :src="imageLink+'/'+valid.segment+'/'+valid.part"
alt="screeshot"> alt="screeshot">
{{ valid.part }} [v{{ valid.data.version }}] {{ valid.part }} [v{{ valid.data.version }}]
@ -124,4 +124,11 @@ export default {
.can-select { .can-select {
cursor: pointer; cursor: pointer;
} }
.rw{
column-count: 3;
div{
margin-bottom: 1rem;
}
}
</style> </style>

@ -28,3 +28,10 @@ body{
#website-preloader{ #website-preloader{
transition: 500ms; transition: 500ms;
} }
.color-bullet{
width: 25px;
height: 25px;
margin: auto;
border-radius: 50%;
}

@ -20,3 +20,49 @@ a,a:visited{
color: var(--xshop-secondary); color: var(--xshop-secondary);
} }
} }
.btn{
border-radius: $xshop-border-radius;
}
.btn-primary{
background: $xshop-primary;
border-color: lighten($xshop-primary,5);
color: $xshop-diff !important;
&:hover{
border-color: lighten($xshop-primary,10);
background: darken($xshop-primary,10); ;
}
}
.btn-outline-primary{
border-color: $xshop-primary;
color: $xshop-primary;
&:hover{
border-color: lighten($xshop-primary,10);
color: $xshop-diff !important;
background: darken($xshop-primary,10); ;
}
}
.btn-secondary{
background: $xshop-secondary;
border-color: lighten($xshop-secondary,5);
color: $xshop-diff !important;
&:hover{
border-color: lighten($xshop-secondary,10);
background: darken($xshop-secondary,10); ;
}
}
.btn-outline-secondary{
border-color: $xshop-secondary;
color: $xshop-secondary;
&:hover{
border-color: lighten($xshop-secondary,10);
color: $xshop-diff !important;
background: darken($xshop-secondary,10); ;
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 92 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 457 KiB

@ -340,9 +340,9 @@ Route::prefix(config('app.panel.prefix'))->name('admin.')->group(
Route::get('test',function (){ Route::get('test',function (){
// return \Resources\Views\Segments\PreloaderCircle::onAdd(); // return \Resources\Views\Segments\PreloaderCircle::onAdd();
Log::info('--test--'); $p = \App\Models\Product::where('id',31)->first();
$i = \App\Models\Product::first();
return get_class($i); return $p->fullMeta();
}); });

Loading…
Cancel
Save