HEX
Server: LiteSpeed
System: Linux s1049.use1.mysecurecloudhost.com 4.18.0-477.27.2.lve.el8.x86_64 #1 SMP Wed Oct 11 12:32:56 UTC 2023 x86_64
User: xedaptot (3356)
PHP: 8.3.31
Disabled: NONE
Upload Files
File: /home/xedaptot/ai.naniguide.com/database/factories/SubscriptionCreditStateFactory.php
<?php

namespace Database\Factories;

use App\Model\SubscriptionCreditState;
use App\Services\Plans\Credits\CreditKey;
use Illuminate\Database\Eloquent\Factories\Factory;

class SubscriptionCreditStateFactory extends Factory
{
    protected $model = SubscriptionCreditState::class;

    public function definition(): array
    {
        return [
            'subscription_id'   => 0, // caller must override with real subscription id
            'credit_key'        => CreditKey::SEND_EMAIL->value,
            'remaining'         => 1000,
            'granted_per_cycle' => 1000,
            'reset_at'          => now()->addMonth(),
            'last_synced_at'    => now(),
        ];
    }

    public function unlimited(): static
    {
        return $this->state([
            'remaining'         => null,
            'granted_per_cycle' => null,
        ]);
    }

    public function forKey(CreditKey $key): static
    {
        return $this->state(['credit_key' => $key->value]);
    }
}