<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class Order extends Model
{
protected $fillable = [
'user_id','order_no','subtotal_cents','total_cents','status',
'customer_name','customer_phone'
];
public function items()
{
return $this->hasMany(OrderItem::class);
}
public function payment()
{
return $this->hasOne(Payment::class);
}
public function getTotalFormattedAttribute(): string
{
return 'RM ' . number_format($this->total_cents / 100, 2);
}
}