Laravel 5 $ request-> input vs Input :: get

Jon*_*Doe 4 php laravel laravel-5

只是想知道之间有什么区别:

$username = $request->input('username');
Run Code Online (Sandbox Code Playgroud)

$username = Input::get('username');
Run Code Online (Sandbox Code Playgroud)

Jai*_*rea 7

没有区别,facade输入从请求中调用输入方法.但是Input::get被弃用了,$request->input而不是代替Input::get

<?php

namespace Illuminate\Support\Facades;

/**
 * @see \Illuminate\Http\Request
 */
class Input extends Facade
{
    /** 
     * Get an item from the input data.
     *
     * This method is used for all request verbs (GET, POST, PUT, and DELETE)
     *
     * @param  string  $key
     * @param  mixed   $default
     * @return mixed
     */
    public static function get($key = null, $default = null)
    {   
        return static::$app['request']->input($key, $default);
    }   

    /** 
     * Get the registered name of the component.
     *
     * @return string
     */
    protected static function getFacadeAccessor()
    {   
        return 'request';
    }   
}
Run Code Online (Sandbox Code Playgroud)