<?php

namespace App\Providers;

use Illuminate\Support\ServiceProvider;

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

    /**
     * Bootstrap any application services.
     */
    public function boot(): void
    {
        \Carbon\Carbon::setLocale('id');
        
        \Illuminate\Support\Facades\Gate::guessPolicyNamesUsing(function ($modelClass) {
            return 'App\\Policies\\' . class_basename($modelClass) . 'Policy';
        });

        // Set custom response for unauthorized access
        \Illuminate\Support\Facades\Gate::define('access-denied', function () {
            return \Illuminate\Auth\Access\Response::deny('Anda tidak memiliki izin untuk mengakses halaman atau data ini.');
        });
    }
}
