<?php

namespace App\Providers;

use Illuminate\Pagination\LengthAwarePaginator;
use Illuminate\Support\Collection;
use Illuminate\Support\Facades\File;
use Illuminate\Support\Facades\Schema;
use Illuminate\Support\ServiceProvider;
use Illuminate\Support\Facades\View;


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

    /**
     * Bootstrap any application services.
     *
     * @return void
     */
    public function boot()
    {
        Schema::defaultStringLength(191);

        error_reporting(E_ALL ^ E_NOTICE ^ E_WARNING);
        $path = storage_path('app/public/thumbnails');
        File::isDirectory($path) or File::makeDirectory($path );

        View::composer(['layouts.backend', 'backend.*'], 'App\Http\View\Composers\BackendComposer');
        View::composer([
            'layouts.frontend',
            'layouts.auth',
            'templates.*',
            'errors.*',
            'emails.*',
            'user.*',
            'auth.*'
        ], 'App\Http\View\Composers\FrontendComposer');

//        Collection::macro('paginate', function($perPage, $total = null, $page = null, $pageName = 'p') {
//            $page = $page ?: LengthAwarePaginator::resolveCurrentPage($pageName);
//            return new LengthAwarePaginator(
//                $this->forPage($page, $perPage),
//                $total ?: $this->count(),
//                $perPage,
//                $page,
//                [
//                    'path' => LengthAwarePaginator::resolveCurrentPath(),
//                    'pageName' => $pageName,
//                ]
//            );
//        });
    }
}
