Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
85.71% |
6 / 7 |
|
50.00% |
1 / 2 |
CRAP | |
0.00% |
0 / 1 |
| OrderItem | |
85.71% |
6 / 7 |
|
50.00% |
1 / 2 |
2.01 | |
0.00% |
0 / 1 |
| casts | |
100.00% |
6 / 6 |
|
100.00% |
1 / 1 |
1 | |||
| order | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| 1 | <?php |
| 2 | |
| 3 | namespace App\Models; |
| 4 | |
| 5 | use Illuminate\Database\Eloquent\Factories\HasFactory; |
| 6 | use Illuminate\Database\Eloquent\Model; |
| 7 | use Illuminate\Database\Eloquent\Relations\BelongsTo; |
| 8 | |
| 9 | class OrderItem extends Model |
| 10 | { |
| 11 | use HasFactory; |
| 12 | |
| 13 | protected $fillable = [ |
| 14 | 'order_id', 'external_product_id', 'external_variant_id', 'name', 'sku', 'quantity', |
| 15 | 'unit_price', 'total_price', 'category_name', 'metadata', |
| 16 | ]; |
| 17 | |
| 18 | protected function casts(): array |
| 19 | { |
| 20 | return [ |
| 21 | 'quantity' => 'integer', |
| 22 | 'unit_price' => 'decimal:2', |
| 23 | 'total_price' => 'decimal:2', |
| 24 | 'metadata' => 'array', |
| 25 | ]; |
| 26 | } |
| 27 | |
| 28 | public function order(): BelongsTo { return $this->belongsTo(Order::class); } |
| 29 | } |