Files
ladill-merchant/app/Models/QrSaleOrder.php
T
isaaccladandCursor 94fac8fbee
Deploy Ladill Merchant / deploy (push) Successful in 27s
Lower sales platform fee from 15% to 9%.
Align merchant settlement and booking checkout with the updated Ladill Pay sales tier.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-11 19:32:24 +00:00

74 lines
2.1 KiB
PHP

<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
class QrSaleOrder extends Model
{
public const STATUS_PENDING = 'pending';
public const STATUS_PAID = 'paid';
public const STATUS_FAILED = 'failed';
public const FULFILLMENT_NEW = 'new';
public const FULFILLMENT_CONFIRMED = 'confirmed';
public const FULFILLMENT_PREPARING = 'preparing';
public const FULFILLMENT_READY = 'ready';
public const FULFILLMENT_DELIVERED = 'delivered';
public const FULFILLMENT_CANCELLED = 'cancelled';
public const FULFILLMENT_STATUSES = [
self::FULFILLMENT_NEW => 'New',
self::FULFILLMENT_CONFIRMED => 'Confirmed',
self::FULFILLMENT_PREPARING => 'Preparing',
self::FULFILLMENT_READY => 'Ready',
self::FULFILLMENT_DELIVERED => 'Delivered',
self::FULFILLMENT_CANCELLED => 'Cancelled',
];
public const PLATFORM_FEE_RATE = 0.09;
protected $fillable = [
'pay_order_id',
'qr_code_id',
'user_id',
'customer_name',
'customer_email',
'customer_phone',
'items',
'amount_ghs',
'platform_fee_ghs',
'merchant_amount_ghs',
'status',
'fulfillment_status',
'payment_reference',
'paid_at',
'metadata',
];
protected $casts = [
'items' => 'array',
'amount_ghs' => 'decimal:2',
'platform_fee_ghs' => 'decimal:2',
'merchant_amount_ghs' => 'decimal:2',
'metadata' => 'array',
'paid_at' => 'datetime',
];
public function fulfillmentLabel(): string
{
return self::FULFILLMENT_STATUSES[$this->fulfillment_status ?? self::FULFILLMENT_NEW] ?? ucfirst((string) $this->fulfillment_status);
}
public function qrCode(): BelongsTo
{
return $this->belongsTo(QrCode::class);
}
public function merchant(): BelongsTo
{
return $this->belongsTo(User::class, 'user_id');
}
}