<?php

namespace App\Providers;

use App\Models\Airline;
use App\Models\Notification;
use App\Models\UserFlight;
use App\Observers\AirlineObserver;
use App\Observers\FlightObserver;
use App\Observers\NotificationObserver;
use Illuminate\Support\Facades\Vite;
use Illuminate\Support\ServiceProvider;
use Illuminate\Support\Facades\RateLimiter;
use Illuminate\Http\Request;
use Illuminate\Cache\RateLimiting\Limit;
use Illuminate\Support\Facades\Mail;

class AppServiceProvider extends ServiceProvider
{
    /**
     * Register any application services.
     */
    public function register(): void
    {
        //
    }

    /**
     * Bootstrap any application services.
     */
    public function boot(): void
    {
        if(!app()->isProduction()){
            Mail::alwaysTo(config('app.test_email'));
        }
        Vite::prefetch(concurrency: 3);
        RateLimiter::for('api', function (Request $request) {
            return $request->user('sanctum')
                ? Limit::perMinute(60)->by($request->user('sanctum')->id)
                : Limit::perMinute(10)->by($request->ip());
        });

    }
}
