*/ protected $fillable = [ 'order_id', 'item_id', 'item_name', 'item_price', 'quantity', 'total_price', 'cooked' ]; /** * The attributes that should be cast. * * @var array */ protected $casts = [ 'item_price' => 'decimal:2', // Pastikan presisi 2 desimal 'total_price' => 'decimal:2', // Pastikan presisi 2 desimal 'quantity' => 'integer', 'created_at' => 'datetime', 'updated_at' => 'datetime', ]; /** * Get the order that owns the order item. */ public function order() { return $this->belongsTo(Order::class, 'order_id', 'id'); } /** * Get the actual menu item associated with the order item. */ public function item() { return $this->belongsTo(Items::class, 'item_id', 'id'); } }