Вход Регистрация
Файл: gapps/vendor/laravel/framework/src/Illuminate/View/Middleware/ShareErrorsFromSession.php
Строк: 59
<?php

namespace IlluminateViewMiddleware;

use 
Closure;
use 
IlluminateSupportViewErrorBag;
use 
IlluminateContractsViewFactory as ViewFactory;

class 
ShareErrorsFromSession
{
    
/**
     * The view factory implementation.
     *
     * @var IlluminateContractsViewFactory
     */
    
protected $view;

    
/**
     * Create a new error binder instance.
     *
     * @param  IlluminateContractsViewFactory  $view
     * @return void
     */
    
public function __construct(ViewFactory $view)
    {
        
$this->view $view;
    }

    
/**
     * Handle an incoming request.
     *
     * @param  IlluminateHttpRequest  $request
     * @param  Closure  $next
     * @return mixed
     */
    
public function handle($requestClosure $next)
    {
        
// If the current session has an "errors" variable bound to it, we will share
        // its value with all view instances so the views can easily access errors
        // without having to bind. An empty bag is set when there aren't errors.
        
$this->view->share(
            
'errors'$request->session()->get('errors') ?: new ViewErrorBag
        
);

        
// Putting the errors in the view for every view allows the developer to just
        // assume that some errors are always available, which is convenient since
        // they don't have to continually run checks for the presence of errors.

        
return $next($request);
    }
}
Онлайн: 0
Реклама