Umsetzung der Warenwirtschafts-/Produktmanagement-Erweiterung gemaess Entwicklungsplan V4.0: - AP-00: Regressionsbasis fuer 5.1-Features (ProductPhase51Test) - AP-01: URL-Bugfixes B1/B2 (suppliers/packaging-items, breitere url-Spalten) - AP-04/04.1: iPad-taugliche, vereinheitlichte Tabellen-Aktionen - AP-05: Einstellungen "Allgemein" mit UST-Saetzen (tax_rates) und Lieferzeit-Vorlagen (delivery_times, inkl. Tage-Feld) - AP-06: Lieferanten um Bestellweg, Bestell-Mail/-URL und Lieferzeit erweitert - AP-07/07.1: INCI um Lieferanten-Mehrfachwahl, UST und Lieferzeit erweitert; Lieferanten-Detailansicht im Modal mit pflegbaren INCI-/Verpackungslisten - AP-08: Einkauf um UST-Snapshot, Netto/Brutto-Automatik und Duplizieren erweitert Entwicklungsplan aktualisiert: alle Klaerungspunkte (§5) vom Kunden beantwortet und in die jeweiligen APs eingearbeitet (AP-02/03/09/13/15), neues AP-18 (Hinweise-Doku unter Einstellungen) ergaenzt. Naechster Schritt eindeutig markiert: AP-09 (Produktion auf Hersteller-Rezeptur, kein Fallback, Warnung).
83 lines
1.9 KiB
PHP
83 lines
1.9 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Database\Factories\SupplierFactory;
|
|
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;
|
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
|
|
|
class Supplier extends Model
|
|
{
|
|
/** @use HasFactory<SupplierFactory> */
|
|
use HasFactory, SoftDeletes;
|
|
|
|
protected $fillable = [
|
|
'name',
|
|
'url',
|
|
'order_method',
|
|
'order_email',
|
|
'order_url',
|
|
'delivery_time',
|
|
'delivery_time_days',
|
|
'contact_person',
|
|
'email',
|
|
'phone',
|
|
'country_id',
|
|
'notes',
|
|
'active',
|
|
];
|
|
|
|
/**
|
|
* @return array<string, string>
|
|
*/
|
|
protected function casts(): array
|
|
{
|
|
return [
|
|
'active' => 'boolean',
|
|
'delivery_time_days' => 'integer',
|
|
];
|
|
}
|
|
|
|
/**
|
|
* @return BelongsTo<Country, $this>
|
|
*/
|
|
public function country(): BelongsTo
|
|
{
|
|
return $this->belongsTo(Country::class);
|
|
}
|
|
|
|
/**
|
|
* @return BelongsToMany<SupplierCategory, $this>
|
|
*/
|
|
public function supplierCategories(): BelongsToMany
|
|
{
|
|
return $this->belongsToMany(
|
|
SupplierCategory::class,
|
|
'supplier_supplier_category',
|
|
'supplier_id',
|
|
'supplier_category_id'
|
|
)->withTimestamps();
|
|
}
|
|
|
|
/**
|
|
* @return HasMany<PackagingItem, $this>
|
|
*/
|
|
public function packagingItems(): HasMany
|
|
{
|
|
return $this->hasMany(PackagingItem::class);
|
|
}
|
|
|
|
/**
|
|
* @return BelongsToMany<Ingredient, $this>
|
|
*/
|
|
public function ingredients(): BelongsToMany
|
|
{
|
|
return $this->belongsToMany(Ingredient::class, 'ingredient_supplier')
|
|
->withPivot(['preferred', 'supplier_sku', 'url'])
|
|
->withTimestamps();
|
|
}
|
|
}
|