20-02-2026

This commit is contained in:
Kevin Adametz 2026-02-20 17:57:50 +01:00
parent 854ce02bf6
commit 4d6b4930b2
128 changed files with 18247 additions and 2093 deletions

View file

@ -2,9 +2,44 @@
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
use Illuminate\Database\Eloquent\Relations\HasMany;
class Category extends Model
{
//
use HasFactory;
protected $fillable = [
'parent_id',
'name',
'slug',
'description',
];
/**
* Übergeordnete Kategorie.
*/
public function parent(): BelongsTo
{
return $this->belongsTo(self::class, 'parent_id');
}
/**
* Untergeordnete Kategorien.
*/
public function children(): HasMany
{
return $this->hasMany(self::class, 'parent_id');
}
/**
* Produkte in dieser Kategorie.
*/
public function products(): BelongsToMany
{
return $this->belongsToMany(Product::class);
}
}