23-01-2026
This commit is contained in:
parent
07959c0ba2
commit
854ce02bf6
166 changed files with 32909 additions and 1262 deletions
|
|
@ -6,6 +6,7 @@ use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
use Illuminate\Database\Eloquent\Relations\HasOne;
|
||||
|
||||
class Partner extends Model
|
||||
{
|
||||
|
|
@ -13,9 +14,22 @@ class Partner extends Model
|
|||
|
||||
protected $fillable = [
|
||||
'company_name',
|
||||
'display_name',
|
||||
'slug',
|
||||
'type',
|
||||
'brand',
|
||||
'hub_id',
|
||||
'parent_partner_id',
|
||||
'salutation',
|
||||
'first_name',
|
||||
'last_name',
|
||||
'street',
|
||||
'house_number',
|
||||
'zip',
|
||||
'city',
|
||||
'country',
|
||||
'phone',
|
||||
'website',
|
||||
'description',
|
||||
'logo_url',
|
||||
'is_active',
|
||||
|
|
@ -50,6 +64,46 @@ class Partner extends Model
|
|||
return $this->hasMany(User::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Für Kunden: Zugeordneter Makler/Händler (Parent-Partner)
|
||||
*/
|
||||
public function parentPartner(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Partner::class, 'parent_partner_id');
|
||||
}
|
||||
|
||||
/**
|
||||
* Für Makler/Händler: Zugeordnete Kunden (Child-Partners)
|
||||
*/
|
||||
public function childPartners(): HasMany
|
||||
{
|
||||
return $this->hasMany(Partner::class, 'parent_partner_id');
|
||||
}
|
||||
|
||||
/**
|
||||
* Alias für parentPartner (für bessere Lesbarkeit im Code)
|
||||
*/
|
||||
public function broker(): BelongsTo
|
||||
{
|
||||
return $this->parentPartner();
|
||||
}
|
||||
|
||||
/**
|
||||
* Alias für childPartners (für bessere Lesbarkeit im Code)
|
||||
*/
|
||||
public function customers(): HasMany
|
||||
{
|
||||
return $this->childPartners();
|
||||
}
|
||||
|
||||
/**
|
||||
* Ein Partner (Manufacturer) kann eine Marke haben
|
||||
*/
|
||||
public function brand(): HasOne
|
||||
{
|
||||
return $this->hasOne(Brand::class);
|
||||
}
|
||||
|
||||
// TODO: Später die Beziehung zu Products hinzufügen
|
||||
// public function products(): HasMany
|
||||
// {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue