diff --git a/app/Http/Controllers/Admin/ProductController.php b/app/Http/Controllers/Admin/ProductController.php index dd01676..8ee6a05 100644 --- a/app/Http/Controllers/Admin/ProductController.php +++ b/app/Http/Controllers/Admin/ProductController.php @@ -19,7 +19,7 @@ class ProductController extends XController // protected $_MODEL_ = Product::class; // protected $SAVE_REQUEST = ProductSaveRequest::class; - protected $cols = ['name','category_id','view_count','sell_count']; + protected $cols = ['name','category_id','view','sell']; protected $extra_cols = ['id','slug','image_index']; protected $searchable = ['name','slug','description','excerpt','sku','table']; diff --git a/app/Http/Controllers/HomeController.php b/app/Http/Controllers/HomeController.php index 4eb084c..600b5f5 100644 --- a/app/Http/Controllers/HomeController.php +++ b/app/Http/Controllers/HomeController.php @@ -35,11 +35,11 @@ class HomeController extends Controller $visits = Visitor::where('created_at', '>=', Carbon::now()->subMonth()) ->groupBy('date') ->orderBy('date', 'DESC') - ->get(array( + ->get([ DB::raw('Date(created_at) as date'), DB::raw('COUNT(*) as "count"'), DB::raw('SUM(visit) as "visits"'), - ))->toArray(); + ])->toArray(); $dates = range((count($visits) - 1) * -1, 0); $dt = new TDate(); array_walk($dates, function (&$item, $key) use ($dt) { diff --git a/app/Models/Category.php b/app/Models/Category.php index c2cc6e6..c8cdebc 100644 --- a/app/Models/Category.php +++ b/app/Models/Category.php @@ -5,11 +5,12 @@ namespace App\Models; use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\SoftDeletes; +use Illuminate\Support\Facades\DB; use Spatie\Translatable\HasTranslations; class Category extends Model { - use HasFactory, HasTranslations,SoftDeletes; + use HasFactory, HasTranslations, SoftDeletes; public $translatable = ['name', 'subtitle', 'description']; @@ -21,6 +22,7 @@ class Category extends Model return \Storage::url('categories/optimized-' . $this->image); } + public function imgOriginalUrl() { if ($this->image == null) { @@ -38,6 +40,7 @@ class Category extends Model return \Storage::url('categories/optimized-' . $this->bg); } + public function bgOriginalUrl() { if ($this->bg == null) { @@ -62,21 +65,35 @@ class Category extends Model return 'slug'; } - public function props(){ + public function props() + { return $this->belongsToMany(Prop::class); } - public function attachs(){ - return $this->morphMany(Attachment::class,'attachable'); + public function attachs() + { + return $this->morphMany(Attachment::class, 'attachable'); } - public function webUrl(){ - return '#';// WIP + public function webUrl() + { + return '#';// WIP return route(''); } - public function products(){ + public function products() + { return $this->belongsToMany(Product::class); } + + public function published($limit = 10, $order = 'id', $dir = 'DESC') + { + return $this->products()->where('status', 1) + ->orderBy($order, $dir)->limit($limit)->get([ + DB::raw('name as "title"'), + 'slug' + ]); + } + } diff --git a/app/Models/Group.php b/app/Models/Group.php index d40a108..cab4777 100644 --- a/app/Models/Group.php +++ b/app/Models/Group.php @@ -5,13 +5,15 @@ namespace App\Models; use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\SoftDeletes; +use Illuminate\Support\Facades\DB; use Spatie\Translatable\HasTranslations; class Group extends Model { - use HasFactory, SoftDeletes,HasTranslations; + use HasFactory, SoftDeletes, HasTranslations; + + public $translatable = ['name', 'subtitle', 'description']; - public $translatable = ['name','subtitle','description']; public function posts() { return $this->belongsToMany(Post::class); @@ -47,6 +49,7 @@ class Group extends Model return \Storage::url('groups/optimized-' . $this->image); } + public function imgOriginalUrl() { if ($this->image == null) { @@ -64,6 +67,7 @@ class Group extends Model return \Storage::url('groups/optimized-' . $this->bg); } + public function bgOriginalUrl() { if ($this->bg == null) { @@ -72,12 +76,21 @@ class Group extends Model return \Storage::url('groups/' . $this->bg); } - public function attachs(){ - return $this->morphMany(Attachment::class,'attachable'); + + public function attachs() + { + return $this->morphMany(Attachment::class, 'attachable'); } - public function webUrl(){ - return '#';// WIP + public function webUrl() + { + return '#';// WIP return route(''); } + + public function published($limit = 10, $order = 'id', $dir = 'DESC') + { + return $this->posts()->where('status', 1) + ->orderBy($order, $dir)->limit($limit)->get(['title', 'slug', 'icon']); + } } diff --git a/database/migrations/2024_05_07_130016_create_products_table.php b/database/migrations/2024_05_07_130016_create_products_table.php index b00e931..fe780dd 100644 --- a/database/migrations/2024_05_07_130016_create_products_table.php +++ b/database/migrations/2024_05_07_130016_create_products_table.php @@ -32,8 +32,8 @@ return new class extends Migration $table->decimal('average_rating',3,2)->unsigned()->nullable()->default(0.00); // $table->unsignedBigInteger('total_sales')->nullable()->default(0); $table->unsignedTinyInteger('status')->default(0); - $table->unsignedBigInteger('view_count')->default(0); - $table->unsignedBigInteger('sell_count')->default(0); + $table->unsignedBigInteger('view')->default(0); + $table->unsignedBigInteger('sell')->default(0); $table->unsignedTinyInteger('image_index')->default(0); $table->softDeletes(); $table->timestamps(); diff --git a/resources/views/segments/menu/AplMenu/AplMenu.blade.php b/resources/views/segments/menu/AplMenu/AplMenu.blade.php new file mode 100644 index 0000000..c4875cc --- /dev/null +++ b/resources/views/segments/menu/AplMenu/AplMenu.blade.php @@ -0,0 +1,102 @@ + diff --git a/resources/views/segments/menu/AplMenu/AplMenu.js b/resources/views/segments/menu/AplMenu/AplMenu.js new file mode 100644 index 0000000..b2aa8bf --- /dev/null +++ b/resources/views/segments/menu/AplMenu/AplMenu.js @@ -0,0 +1,14 @@ +const toggleSideMenu = function (e) { + e.preventDefault(); + let txt = ''; + document.querySelector('#reps-menu').innerHTML = txt; +}; +document.addEventListener('DOMContentLoaded',function () { + document.querySelector('#toggler-menu').addEventListener('click',toggleSideMenu); +}); diff --git a/resources/views/segments/menu/AplMenu/AplMenu.json b/resources/views/segments/menu/AplMenu/AplMenu.json new file mode 100644 index 0000000..9ac46f4 --- /dev/null +++ b/resources/views/segments/menu/AplMenu/AplMenu.json @@ -0,0 +1,10 @@ +{ + "name": "AplMenu", + "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/menu/AplMenu/AplMenu.php b/resources/views/segments/menu/AplMenu/AplMenu.php new file mode 100644 index 0000000..89e22dc --- /dev/null +++ b/resources/views/segments/menu/AplMenu/AplMenu.php @@ -0,0 +1,31 @@ +section = 'theme'; + $setting->key = $part->area->name . '_' . $part->part.'_menu'; + $setting->value = Menu::first()->id; + $setting->type = 'MENU'; + $setting->size = 12; + $setting->title = $part->area->name . ' ' . $part->part .' menu'; + $setting->save(); + } + public static function onRemove(Part $part = null) + { + Setting::where('key',$part->area->name . '_' . $part->part.'_menu')->first()?->delete(); + } + public static function onMount(Part $part = null) + { + return $part; + } +} diff --git a/resources/views/segments/menu/AplMenu/AplMenu.scss b/resources/views/segments/menu/AplMenu/AplMenu.scss new file mode 100644 index 0000000..a28a9cc --- /dev/null +++ b/resources/views/segments/menu/AplMenu/AplMenu.scss @@ -0,0 +1,149 @@ +#AplMenu { + position: fixed; + left: 0; + top: 0; + right: 0; + z-index: 99; + background: #434344; + transition: 200ms; + + #logo-menu{ + a{ + padding-top: 7px; + } + img{ + width: 35px; + height: 35px; + } + } + + + #toggler-menu,#reps-menu{ + display: none; + } + + &:hover{ + background: #202124; + } + + > ul { + list-style: none; + display: flex; + flex-direction: row; + align-items: center; + justify-content: space-between; + padding: 0; + margin: 0 auto; + + > li { + color: white; + text-align: center; + height: 47px; + + div.sub-menu{ + position: absolute; + top: 100%; + width: 100vw; + background: #202124; + left: 0; + max-height: 0; + transition: 900ms; + overflow: hidden; + .container{ + display: grid; + grid-auto-columns: minmax(0, 1fr); + grid-auto-flow: column; + grid-gap: 1rem; + text-align: start; + padding-bottom: 2rem; + + ul{ + list-style: none; + padding: 0 1rem 0 1rem; + li{ + margin: .75rem 0; + } + a{ + display: inline-block; + font-weight: 500; + padding: 0; + } + } + h4{ + padding-top: 2rem; + margin: .2rem; + font-size: 15px; + + } + h3{ + font-weight: 700; + font-size: 20px; + margin: 0; + } + p{ + padding: 1rem 0; + } + } + } + + &:hover{ + div.sub-menu{ + max-height: 100vh; + } + } + + a { + font-weight: 200; + color: white; + display: block; + padding: .7rem 0; + } + } + } + + /*-768px width*/ + @media (max-width: 768px) { + #toggler-menu{ + display: block; + + + } + + #logo-menu{ + flex-grow: 1; + } + + > ul { + > li{ + display: none; + } + .icon-menu{ + display: block; + padding: 0 1rem; + + } + } + #reps-menu{ + overflow-y: hidden; + color: white; + display: block; + ul{ + li{ + list-style: none; + padding: .5rem; + .sub-menu{ + display: none; + } + } + h3{ + padding: 0; + margin: 0; + } + } + a{ + color: white; + font-size: 16px; + } + } + } +} diff --git a/resources/views/segments/menu/AplMenu/screenshot.png b/resources/views/segments/menu/AplMenu/screenshot.png new file mode 100644 index 0000000..5c83205 Binary files /dev/null and b/resources/views/segments/menu/AplMenu/screenshot.png differ