58 lines
1.3 KiB
PHP
58 lines
1.3 KiB
PHP
<?php
|
|
|
|
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\HasMany;
|
|
|
|
class Partner extends Model
|
|
{
|
|
use HasFactory;
|
|
|
|
protected $fillable = [
|
|
'company_name',
|
|
'slug',
|
|
'type',
|
|
'hub_id',
|
|
'description',
|
|
'logo_url',
|
|
'is_active',
|
|
'setup_completed',
|
|
'setup_completed_at',
|
|
'delivery_radius_km',
|
|
'assembly_radius_km',
|
|
'provision_fixed_amount',
|
|
'provision_rate_percentage',
|
|
];
|
|
|
|
protected $casts = [
|
|
'is_active' => 'boolean',
|
|
'setup_completed' => 'boolean',
|
|
'setup_completed_at' => 'datetime',
|
|
];
|
|
|
|
/**
|
|
* Ein Partner (Händler/Makler) kann einem Hub zugeordnet sein.
|
|
* Ein Hersteller ist evtl. "global" (hub_id = null).
|
|
*/
|
|
public function hub(): BelongsTo
|
|
{
|
|
return $this->belongsTo(Hub::class);
|
|
}
|
|
|
|
/**
|
|
* Ein Partner (Firma) kann mehrere User-Logins haben.
|
|
*/
|
|
public function users(): HasMany
|
|
{
|
|
return $this->hasMany(User::class);
|
|
}
|
|
|
|
// TODO: Später die Beziehung zu Products hinzufügen
|
|
// public function products(): HasMany
|
|
// {
|
|
// return $this->hasMany(Product::class);
|
|
// }
|
|
}
|