feat: implement AI styling foundation and billing scope rework
This commit is contained in:
60
app/Models/AiUsageLedger.php
Normal file
60
app/Models/AiUsageLedger.php
Normal file
@@ -0,0 +1,60 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
|
||||
class AiUsageLedger extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
public const TYPE_DEBIT = 'debit';
|
||||
|
||||
public const TYPE_CREDIT = 'credit';
|
||||
|
||||
public const TYPE_REFUND = 'refund';
|
||||
|
||||
public const TYPE_ADJUSTMENT = 'adjustment';
|
||||
|
||||
protected $fillable = [
|
||||
'tenant_id',
|
||||
'event_id',
|
||||
'request_id',
|
||||
'entry_type',
|
||||
'quantity',
|
||||
'unit_cost_usd',
|
||||
'amount_usd',
|
||||
'currency',
|
||||
'package_context',
|
||||
'notes',
|
||||
'recorded_at',
|
||||
'metadata',
|
||||
];
|
||||
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'unit_cost_usd' => 'decimal:5',
|
||||
'amount_usd' => 'decimal:5',
|
||||
'recorded_at' => 'datetime',
|
||||
'metadata' => 'array',
|
||||
];
|
||||
}
|
||||
|
||||
public function tenant(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Tenant::class);
|
||||
}
|
||||
|
||||
public function event(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Event::class);
|
||||
}
|
||||
|
||||
public function request(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(AiEditRequest::class, 'request_id');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user