vicnumb's avatar

Call to undefined method ... ::fails()

why this construction works on failure:

public function registersimple(RegisterSimpleRequest $request){
if ($request->fails()){
  return redirect()->back()->withErrors($request->all());
}else{
//
}

}

while on success I get this error:

Call to undefined method App\Http\Requests\RegisterSimpleRequest::fails()

0 likes
1 reply
vicnumb's avatar
vicnumb
OP
Best Answer
Level 1

okay, found the solution Thank you All very much :)

on calling this construction:

use App\Http\Requests\RegisterSimpleRequest;
public function registersimple(RegisterSimpleRequest $request){
...
}

and havig a defined request rule, function content is executed only in case $request is not failed, so this construction is not necesary:

if($request->fails()){
...
}

Please or to participate in this conversation.