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).
118 lines
3.8 KiB
PHP
118 lines
3.8 KiB
PHP
<?php
|
|
|
|
/**
|
|
* Created by Reliese Model.
|
|
*/
|
|
|
|
namespace App\Models;
|
|
|
|
use Carbon\Carbon;
|
|
use Illuminate\Database\Eloquent\Collection;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
|
|
|
/**
|
|
* Class Ingredient
|
|
*
|
|
* @property int $id
|
|
* @property string $name
|
|
* @property string $trans_name
|
|
* @property string $inci
|
|
* @property string $trans_inci
|
|
* @property string $effect
|
|
* @property string $trans_effect
|
|
* @property bool $active
|
|
* @property int $pos
|
|
* @property Carbon $created_at
|
|
* @property Carbon $updated_at
|
|
* @property Collection|Product[] $products
|
|
* @property-read Collection|ProductIngredient[] $product_ingredients
|
|
* @property-read int|null $product_ingredients_count
|
|
* @property-read int|null $products_count
|
|
*
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Ingredient newModelQuery()
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Ingredient newQuery()
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Ingredient query()
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Ingredient whereActive($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Ingredient whereCreatedAt($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Ingredient whereEffect($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Ingredient whereId($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Ingredient whereInci($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Ingredient whereName($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Ingredient wherePos($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Ingredient whereTransEffect($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Ingredient whereTransInci($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Ingredient whereTransName($value)
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Ingredient whereUpdatedAt($value)
|
|
*
|
|
* @mixin \Eloquent
|
|
*/
|
|
class Ingredient extends Model
|
|
{
|
|
protected $table = 'ingredients';
|
|
|
|
protected $casts = [
|
|
'active' => 'bool',
|
|
'pos' => 'int',
|
|
'default_factor' => 'decimal:2',
|
|
'min_stock_alert' => 'decimal:2',
|
|
'delivery_time_days' => 'integer',
|
|
];
|
|
|
|
protected $fillable = [
|
|
'name',
|
|
'trans_name',
|
|
'inci',
|
|
'trans_inci',
|
|
'effect',
|
|
'trans_effect',
|
|
'active',
|
|
'pos',
|
|
'default_factor',
|
|
'min_stock_alert',
|
|
'material_quality_id',
|
|
'tax_rate_id',
|
|
'delivery_time',
|
|
'delivery_time_days',
|
|
];
|
|
|
|
/**
|
|
* @return BelongsTo<MaterialQuality, $this>
|
|
*/
|
|
public function materialQuality(): BelongsTo
|
|
{
|
|
return $this->belongsTo(MaterialQuality::class);
|
|
}
|
|
|
|
/**
|
|
* @return BelongsTo<TaxRate, $this>
|
|
*/
|
|
public function taxRate(): BelongsTo
|
|
{
|
|
return $this->belongsTo(TaxRate::class);
|
|
}
|
|
|
|
/**
|
|
* @return BelongsToMany<Supplier, $this>
|
|
*/
|
|
public function suppliers(): BelongsToMany
|
|
{
|
|
return $this->belongsToMany(Supplier::class, 'ingredient_supplier')
|
|
->withPivot(['preferred', 'supplier_sku', 'url'])
|
|
->withTimestamps();
|
|
}
|
|
|
|
public function products()
|
|
{
|
|
return $this->belongsToMany(Product::class, 'product_ingredients')
|
|
->withPivot('id', 'pos', 'gram', 'factor')
|
|
->withTimestamps()
|
|
->orderByPivot('pos');
|
|
}
|
|
|
|
public function product_ingredients()
|
|
{
|
|
return $this->hasMany(ProductIngredient::class, 'ingredient_id');
|
|
}
|
|
}
|