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);
$scss = <<<DOC
#$part {
.$part {
// scss
}
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 . '.json', json_encode($detail,JSON_PRETTY_PRINT));
file_put_contents($folderPath . '/' . ucfirst($part) . '.php', $handler);

@ -3,6 +3,7 @@
use App\Helpers;
use App\Models\Setting;
use App\Models\Group;
use App\Models\Category;
use App\Models\Area;
use App\Models\Part;
use Illuminate\Support\Facades\Route;
@ -776,3 +777,15 @@ function getGroupPostsBySetting($key, $limit = 10)
return Group::where('id', getSetting($key) ?? 1)->first()
->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::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');
logAdmin(__METHOD__,__CLASS__,$area->id);

@ -83,7 +83,7 @@ class SettingController extends Controller
$files = $request->allFiles();
if (isset($files['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']);
}else{
$file->move(public_path('upload/images/'), str_replace('_','.',$index) );//store('/images/'.,['disk' => 'public']);

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

@ -24,17 +24,19 @@ class Product extends Model implements HasMedia
'qidz' => 'array'
];
public function attachs(){
return $this->morphMany(Attachment::class,'attachable');
public function attachs()
{
return $this->morphMany(Attachment::class, 'attachable');
}
protected $guarded = [];
public function getQzAttribute(){
public function getQzAttribute()
{
$result = [];
foreach ($this->quantities as $q) {
if ($q->count > 0){
if ($q->count > 0) {
$q->data = json_decode($q->data);
$result[] = $q;
}
@ -42,13 +44,15 @@ class Product extends Model implements HasMedia
return $result;
}
public function getQidzAttribute(){
public function getQidzAttribute()
{
return $this->quantities()->pluck('id')->toArray();
}
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
{
@ -73,7 +77,7 @@ class Product extends Model implements HasMedia
->nonQueued()
->format(getSetting('optimize'));
if (getSetting('watermark')){
if (getSetting('watermark')) {
$mc->watermark(public_path('upload/images/logo.png'),
AlignPosition::BottomLeft, 5, 5, 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_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) {
return $this->getMedia()[$this->image_index]->getUrl('product-image');
} else {
return asset('assets/upload/logo.svg');
}
}
public function orginalImageUrl(){
public function originalImageUrl()
{
if ($this->getMedia()->count() > 0) {
return $this->getMedia()[$this->image_index]->getUrl();
} else {
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])) {
return $this->getMedia()[1]->getUrl('product-image');
} else {
return asset('assets/upload/logo.svg');
}
}
public function thumbUrl(){
public function thumbUrl()
{
if ($this->getMedia()->count() > 0) {
return $this->getMedia()[$this->image_index]->getUrl('product-thumb');
} else {
return asset('assets/upload/logo.svg');
}
}
public function thumbUrl2(){
public function thumbUrl2()
{
if ($this->getMedia()->count() > 0 && isset($this->getMedia()[1])) {
return $this->getMedia()[1]->getUrl('product-thumb');
} 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 route('');
}

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

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

@ -11,10 +11,10 @@
</span>
</div>
<div class="part-body">
<div class="row">
<div class="rw">
<template v-for="(valid,i) in valids">
<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"
alt="screeshot">
{{ valid.part }} [v{{ valid.data.version }}]
@ -124,4 +124,11 @@ export default {
.can-select {
cursor: pointer;
}
.rw{
column-count: 3;
div{
margin-bottom: 1rem;
}
}
</style>

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

@ -20,3 +20,49 @@ a,a:visited{
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 (){
// return \Resources\Views\Segments\PreloaderCircle::onAdd();
Log::info('--test--');
$i = \App\Models\Product::first();
return get_class($i);
$p = \App\Models\Product::where('id',31)->first();
return $p->fullMeta();
});

Loading…
Cancel
Save