php-commerce/Models/CouponUsage.php
Snider a774f4e285 refactor: migrate namespace from Core\Commerce to Core\Mod\Commerce
Align commerce module with the monorepo module structure by updating
all namespaces to use the Core\Mod\Commerce convention. This change
supports the recent monorepo separation and ensures consistency with
other modules.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-27 16:23:12 +00:00

62 lines
1.2 KiB
PHP

<?php
namespace Core\Mod\Commerce\Models;
use Core\Mod\Tenant\Models\Workspace;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
/**
* CouponUsage model for tracking coupon redemptions.
*
* @property int $id
* @property int $coupon_id
* @property int $workspace_id
* @property int $order_id
* @property float $discount_amount
* @property \Carbon\Carbon $created_at
*/
class CouponUsage extends Model
{
public $timestamps = false;
protected $fillable = [
'coupon_id',
'workspace_id',
'order_id',
'discount_amount',
];
protected $casts = [
'discount_amount' => 'decimal:2',
'created_at' => 'datetime',
];
// Relationships
public function coupon(): BelongsTo
{
return $this->belongsTo(Coupon::class);
}
public function workspace(): BelongsTo
{
return $this->belongsTo(Workspace::class);
}
public function order(): BelongsTo
{
return $this->belongsTo(Order::class);
}
// Boot
protected static function boot()
{
parent::boot();
static::creating(function ($usage) {
$usage->created_at = now();
});
}
}