laravel 5.4报错“Request::session() should not be called statically”

使用 Laravel 5.4, 重写了一下自带的RegisterController 中的validator()方法:

    <?php
    
    namespace App\Http\Controllers\Auth;
    
    use Illuminate\Http\Request;
    
    
    class RegisterController extends Controller
    {
    
        protected function validator(array $data)
        {
            $validationCode = Request::session()->get('validation_code', '');
            return Validator::make($data, [
                'name' => 'required|max:255',
                'role' => 'required|in:1,2',
                'email' => 'required|email|max:255|unique:users',
                'password' => 'required|min:6|confirmed',
                'validation_code' => 'required|in:' . $validationCode
            ]);
        }
    
    }

报错:

    Non-static method Illuminate\Http\Request::session() should not be called statically

在laravel 5.3中是不会报错的,怎么办?

JellyBool
修改的评论也不能少于六个字哦!