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 = '