# Project Documentation

## Subscriptions Management

### 1. Daily Subscription Check
A scheduled task runs every day to check for expired subscriptions. It cancels expired subscriptions and resets the user's coins and top-up balance to zero.

**Running the Check:**
The expiration check can be run manually or via the scheduler (defined in `bootstrap/app.php`).

- **Manual:** `php artisan subscriptions:check-expired`
- **Automated:** Add this to your server's crontab:
  ```bash
  * * * * * cd /path-to-your-project && php artisan schedule:run >> /dev/null 2>&1
  ```

### 2. Background Tasks (Queues)
The project uses queues for background tasks such as sending payment success and failure notifications.

**To run the queue worker:**
```bash
php artisan queue:work
```

---

## Technical Details

### Models
- **Subscription**: Manages user plans, status, and periods.
- **Coin**: Manages user's available credits and top-up balance.
- **Transaction**: Records all purchase history.

### Listeners
- `SendPaymentSuccessNotification`: Queued listener that sends an email when a payment is successful.
- `SendPaymentFailedNotification`: Queued listener that sends an email when a payment fails.

# Run Seeders
```php
Route::get('/database-seed', function () {
    \Illuminate\Support\Facades\Artisan::call('migrate:fresh --seed');
    return redirect()->back();
})->name('database-seed');
```
