New Initial Commit

This commit is contained in:
twotalesanimation
2025-12-09 12:04:54 +02:00
commit 6de01c13c5
350 changed files with 42032 additions and 0 deletions
+38
View File
@@ -0,0 +1,38 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Str;
class Category extends Model
{
protected $fillable = [
'name',
'slug',
'description',
'image'
];
protected static function boot()
{
parent::boot();
static::creating(function ($category) {
if (empty($category->slug)) {
$category->slug = Str::slug($category->name);
}
});
static::updating(function ($category) {
if ($category->isDirty('name') && !$category->isDirty('slug')) {
$category->slug = Str::slug($category->name);
}
});
}
public function products()
{
return $this->hasMany(Product::class);
}
}