72 lines
1.5 KiB
PHP
72 lines
1.5 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use App\User;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|
use Illuminate\Database\Eloquent\Relations\HasMany;
|
|
|
|
class Production extends Model
|
|
{
|
|
protected $fillable = [
|
|
'product_id',
|
|
'location_id',
|
|
'produced_by',
|
|
'produced_at',
|
|
'quantity',
|
|
'notes',
|
|
'mhd_warning',
|
|
];
|
|
|
|
/**
|
|
* @return array<string, string>
|
|
*/
|
|
protected function casts(): array
|
|
{
|
|
return [
|
|
'produced_at' => 'date',
|
|
'mhd_warning' => 'boolean',
|
|
];
|
|
}
|
|
|
|
/**
|
|
* @return BelongsTo<Product, $this>
|
|
*/
|
|
public function product(): BelongsTo
|
|
{
|
|
return $this->belongsTo(Product::class);
|
|
}
|
|
|
|
/**
|
|
* @return BelongsTo<Location, $this>
|
|
*/
|
|
public function location(): BelongsTo
|
|
{
|
|
return $this->belongsTo(Location::class);
|
|
}
|
|
|
|
/**
|
|
* @return BelongsTo<User, $this>
|
|
*/
|
|
public function producedByUser(): BelongsTo
|
|
{
|
|
return $this->belongsTo(User::class, 'produced_by');
|
|
}
|
|
|
|
/**
|
|
* @return HasMany<ProductionIngredient, $this>
|
|
*/
|
|
public function productionIngredients(): HasMany
|
|
{
|
|
return $this->hasMany(ProductionIngredient::class);
|
|
}
|
|
|
|
/**
|
|
* @return HasMany<ProductionPackaging, $this>
|
|
*/
|
|
public function productionPackagings(): HasMany
|
|
{
|
|
return $this->hasMany(ProductionPackaging::class);
|
|
}
|
|
}
|