Laravel 7 Class 'App\Http\Controllers\Validator' not found

Laravel 7

Nicesnippets

1010

10-04-2020


Hello Friends,

Laravel also provide manually validation check. if you have to use then you have to use "Validator" class at controller top. when you get 'App\Http\Controllers\Validator' not found this Exception then use "use Validator" in controller. also get this type of exception class 'app http controllers validator' not found.

you have to simply use at top.

use Validator;

namespace App\Http\Controllers;

use Illuminate\Http\Request;

use Validator;

class RegisterController extends Controller

{

public function store(Request $request)

{

$input = $request->all();

$validator = Validator::make($input, [

'name' => 'required',

'email' => 'required',

'password' => 'required_with:confirm_password|same:confirm_password',

]);

if ($validator->passes()) {

return true;

}

return redirect()->back()

->withErrors($validator)

->withInput();

}

}

I hope it can help you...