<?php

namespace App\Providers;

use Faker\Factory as FakerFactory;
use Faker\Generator as FakerGenerator;
use Illuminate\Contracts\Container\BindingResolutionException;
use Illuminate\Support\Facades\Schema;
use Illuminate\Support\ServiceProvider;
use Laravel\Socialite\Contracts\Factory;

class AppServiceProvider extends ServiceProvider
{
    /**
     * Bootstrap any application services.
     *
     * @return void
     * @throws BindingResolutionException
     */
    public function boot()
    {
        Schema::defaultStringLength(191);

        /** Apple signIn Provider */
        $socialite = $this->app->make(Factory::class);
        $socialite->extend(
            'sign-in-with-apple',
            function ($app) use ($socialite) {
                $config = $app['config']['services.sign_in_with_apple'];

                return $socialite
                    ->buildProvider(SignInWithAppleProvider::class, $config);
            }
        );
    }

    /**
     * Register any application services.
     * @return void
     */
    public function register()
    {
//        $this->app->singleton(
//            FakerGenerator::class, function () {
//            return FakerFactory::create('ru_RU');
//        });
    }
}
