Add all files

This commit is contained in:
root
2025-11-30 11:57:22 +01:00
parent 2ee51cac4f
commit 044271db3d
1476 changed files with 142544 additions and 0 deletions

42
app/Models/Category.php Normal file
View File

@@ -0,0 +1,42 @@
<?php
namespace App\Models;
use App\Observers\CategoryObserver;
use Illuminate\Database\Eloquent\Attributes\ObservedBy;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\HasMany;
#[ObservedBy(CategoryObserver::class)]
class Category extends Model
{
use HasFactory;
protected $guarded = [];
/**
* Get the products of the category.
*/
public function products(): HasMany
{
return $this->hasMany(Product::class);
}
/**
* Get the parent category of the category.
*/
public function parent(): BelongsTo
{
return $this->belongsTo(Category::class, 'parent_id');
}
/**
* Get the children categories of the category.
*/
public function children(): HasMany
{
return $this->hasMany(Category::class, 'parent_id');
}
}