<?php

namespace AleshaCMS\Providers;

use Illuminate\Console\Application as Artisan;
use Illuminate\Support\ServiceProvider;

class AppServiceProvider extends ServiceProvider
{
    public function register(): void
    {
        Artisan::starting(function (Artisan $artisan) {
            $artisan->setName('AleshaCMS');
        });
    }

    public function boot(): void
    {
        try {
            $tz = \AleshaCMS\Models\CMS\Setting::get('site_timezone');
            if ($tz && in_array($tz, \DateTimeZone::listIdentifiers(), true)) {
                config(['app.timezone' => $tz]);
                date_default_timezone_set($tz);
            }
        } catch (\Throwable) {
            //
        }
    }
}
