File: /home/xedaptot/be.naniguide.com/app/Model/SubscriptionCreditState.php
<?php
namespace App\Model;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
/**
* subscription_credit_state — cold-path snapshot of credits per subscription.
*
* Hot-path (CreditsService::canUse/consume) uses CreditTracker (file-based). This
* table is the eventually-consistent durable view for admin UI, API, and audit.
* Synced from tracker by CreditStateSyncJob.
*
* See docs/payment-order-plan-subscription-saas/SUBSCRIPTION-COMPREHENSIVE-DESIGN.md §3.2.
*/
class SubscriptionCreditState extends Model
{
use HasFactory;
protected $connection = 'mysql';
protected $table = 'subscription_credit_state';
protected $fillable = [
'subscription_id',
'credit_key',
'remaining',
'granted_per_cycle',
'reset_at',
'last_synced_at',
];
protected $casts = [
'remaining' => 'integer',
'granted_per_cycle' => 'integer',
'reset_at' => 'datetime',
'last_synced_at' => 'datetime',
];
public function subscription()
{
return $this->belongsTo(Subscription::class);
}
protected static function newFactory()
{
return \Database\Factories\SubscriptionCreditStateFactory::new();
}
}