<?php

namespace App\Providers;

use Illuminate\Support\ServiceProvider;
use DB;
use App\Services\TwilioService;
use Carbon\Carbon;
use App\Models\Settings;

class AppServiceProvider extends ServiceProvider
{
    /**
     * Register any application services.
     *
     * @return void
     */
    public function register()
    {
        $this->app->bind(TwilioService::class, function ($app) {
            return new TwilioService();
        });
    }

    /**
     * Bootstrap any application services.
     *
     * @return void
     */
    public function boot()
    {
        $value = Settings::findConfigValue(Settings::TIME_AM_PM);
        if(isset($value) && strtolower($value) === "true"){
            Carbon::setToStringFormat('Y-m-d h:i:s A');
        }else{
            Carbon::setToStringFormat('Y-m-d H:i:s');
        }
        DB::connection()
            ->getDoctrineSchemaManager()
            ->getDatabasePlatform()
            ->registerDoctrineTypeMapping('enum', 'string');
    }
}
