<?php

namespace App\Providers;

use Illuminate\Support\ServiceProvider;
use Illuminate\Http\Request;
use App\Http\Traits\AgentTrait;

class AppServiceProvider extends ServiceProvider
{
    use AgentTrait;

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

    /**
     * Bootstrap any application services.
     */
    public function boot(Request $request): void
    {
        $baseURL = env('APP_URL');
        $fullURL = currentURL();
        $charset = config('app.locale');
        $date = date('Y-m-d');
        $datetime = date('H:i:s');

        $ipAddress = $request->ip();
        $referer = $request->headers->get('referer');
        $userAgent = $request->headers->get('user-agent');
        $deviceType = $this->deviceType();
        $device = $this->device();
        $platform = $this->platform();
        $browser = $this->browser();

        defined('BASE_URL') OR define('BASE_URL', $baseURL);
        defined('FULL_URL') OR define('FULL_URL', $fullURL);
        defined('CHARSET') OR define('CHARSET', $charset);
        defined('DATE') OR define('DATE', $date);
        defined('DATETIME') OR define('DATETIME', $datetime);
        defined('IP_ADDRESS') OR define('IP_ADDRESS', $ipAddress);
        defined('REFERER') OR define('REFERER', $referer);
        defined('USER_AGENT') OR define('USER_AGENT', $userAgent);
        defined('DEVICE') OR define('DEVICE', $device);
        defined('DEVICE_TYPE') OR define('DEVICE_TYPE', $deviceType);
        defined('PLATFORM') OR define('PLATFORM', $platform);
        defined('BROWSER') OR define('BROWSER', $browser);
    }
}
