*/ protected $fillable = [ 'physical_item_id', 'supplier_id', 'count', 'price', 'bought', 'description', 'note', 'stock_position_id', 'country_of_origin_id', 'on_the_way', 'stock_batch_id', 'created_by', 'updated_by', ]; /** * The attributes that should be cast. * * @var array */ protected $casts = [ 'bought' => 'date', 'on_the_way' => 'boolean', ]; /** * Get the physical item associated with the stock entry. */ public function physicalItem(): BelongsTo { return $this->belongsTo(PhysicalItem::class, 'physical_item_id'); } /** * Get the supplier associated with the stock entry. */ public function supplier(): BelongsTo { return $this->belongsTo(Supplier::class, 'supplier_id'); } /** * Get the stock position associated with the stock entry. */ public function stockPosition(): BelongsTo { return $this->belongsTo(StockPosition::class); } /** * Get the stock batch associated with the stock entry. */ public function stockBatch(): BelongsTo { return $this->belongsTo(StockBatch::class); } /** * Get the attributes for this stock entry. */ public function attributes(): BelongsToMany { return $this->belongsToMany( StockAttributes::class, 'stock_entry2attributes', 'stock_entry_id', 'stock_attributes_id' )->withPivot('stock_attribute_value_id'); } public function countryOfOrigin(): BelongsTo { return $this->belongsTo(OriginCountry::class, 'country_of_origin_id'); } }