Laravel $ request-> all()抛出'无法访问空属性'消息

I'm having a weird problem trying to validate the fields on a form with laravel. According to the documentation, in order to do so I need to do this:

Validator::make($this->$request->all(), $this->$validationRules)

But currently I'm getting this annoying message 'Cannot access empty property'.

I have tracked the error to this expression $this->$request->all(), as it seems that all() property is not defined... Weird thing cause if I do, for instance something like $this->request->input('name') I'll get the value sent by the input with name='name' correctly on my controller .

Why is that property seems to be empty? Is there anything I'm missing to create my validations properly?

Thanks!

Use this:

$this->request

Instead of this:

$this->$request

Also, check if you're injecting Request object first:

public function method(Request $request)
{
    $this->request = $request;

Or you could just use request() global helper:

request()->all();