<?php

namespace App\Providers;

use Illuminate\Support\Facades\Schema;
use Illuminate\Support\ServiceProvider;
use Illuminate\Cache\RateLimiting\Limit;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\RateLimiter;

class AppServiceProvider extends ServiceProvider
{
    /**
     * Register any application services.
     *
     * @return void
     */
    public function register()
    {
        Schema::defaultStringLength(191);
    }

    /**
     * Bootstrap any application services.
     *
     * @return void
     */
    public function boot()
    {
        if (!file_exists(storage_path('framework/sessions'))) {
            mkdir(storage_path('framework/sessions'), 0777, true);
        }

        //From Shipping Portal
        // RateLimiter::for('api', function (Request $request) {
        //     return Limit::perMinute(300)->by($request->user()?->id ?: $request->ip());
        // });
    }
}
