<?php

namespace App\Providers;

use App\Models\User;
use App\Models\WalletTransaction;
use App\Observers\UserObserver;
use App\Observers\WalletTransactionObserver;
use Illuminate\Support\ServiceProvider;
use Illuminate\Cache\RateLimiting\Limit;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Artisan;
use Illuminate\Support\Facades\RateLimiter;
class AppServiceProvider extends ServiceProvider
{
    /**
     * Register any application services.
     */
    public function register(): void
    {
        //
    }

    /**
     * Bootstrap any application services.
     */




public function boot(): void
{
    Artisan::call('queue:work', ['--stop-when-empty' => true]);
    WalletTransaction::observe(WalletTransactionObserver::class);
   User::observe(UserObserver::class);
    RateLimiter::for('api', function (Request $request) {
        return Limit::perMinute(60)->by($request->user()?->id ?: $request->ip());
    });
}
}
