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>
62 lines
1.2 KiB
PHP
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();
|
|
});
|
|
}
|
|
}
|