Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
4 / 4 |
|
100.00% |
4 / 4 |
CRAP | |
100.00% |
1 / 1 |
| Bom | |
100.00% |
4 / 4 |
|
100.00% |
4 / 4 |
4 | |
100.00% |
1 / 1 |
| auditName | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| product | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| items | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| productionOrders | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| 1 | <?php |
| 2 | |
| 3 | namespace App\Models; |
| 4 | |
| 5 | use App\Models\admin\Product; |
| 6 | use App\Support\Auditable; |
| 7 | use Illuminate\Database\Eloquent\Model; |
| 8 | |
| 9 | /** |
| 10 | * A recipe: this product (finished or semi-finished) is made from these |
| 11 | * bom_items (raw materials). See App\Services\Manufacturing\BomService for |
| 12 | * exploding a BOM into required quantities, and ProductionService for |
| 13 | * actually consuming/producing stock from one. |
| 14 | */ |
| 15 | class Bom extends Model |
| 16 | { |
| 17 | use Auditable; |
| 18 | |
| 19 | protected $fillable = ['product_id', 'version', 'is_active', 'name', 'note', 'created_by']; |
| 20 | |
| 21 | protected $casts = [ |
| 22 | 'is_active' => 'boolean', |
| 23 | 'version' => 'integer', |
| 24 | ]; |
| 25 | |
| 26 | protected function auditName(): string |
| 27 | { |
| 28 | return 'bom'; |
| 29 | } |
| 30 | |
| 31 | public function product() |
| 32 | { |
| 33 | return $this->belongsTo(Product::class, 'product_id'); |
| 34 | } |
| 35 | |
| 36 | public function items() |
| 37 | { |
| 38 | return $this->hasMany(BomItem::class); |
| 39 | } |
| 40 | |
| 41 | public function productionOrders() |
| 42 | { |
| 43 | return $this->hasMany(ProductionOrder::class); |
| 44 | } |
| 45 | } |