'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 */ public function materialQuality(): BelongsTo { return $this->belongsTo(MaterialQuality::class); } /** * @return BelongsTo */ public function taxRate(): BelongsTo { return $this->belongsTo(TaxRate::class); } /** * @return BelongsToMany */ 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'); } }