I am trying to do registration of multi-user in my registration controller and used the following code and checked. But it shows me error:
Method App\Http\Controllers\Auth\RegisterController::validator does not exist.
<?php namespace App\Http\Controllers\Auth; use App\Admin; use App\Manager; use App\Http\Controllers\Controller; use Illuminate\Support\Facades\Hash; use Illuminate\Support\Facades\Validator; use Illuminate\Foundation\Auth\RegistersUsers; use Illuminate\Foundation\Validation\ValidatesRequests; use Illuminate\Http\Request; class RegisterController extends Controller { use RegistersUsers; public function __construct() { $this->middleware('guest'); $this->middleware('guest:admin'); $this->middleware('guest:manager'); } protected function createAdmin(Request $request) { $this->validator($request->all())->validate(); $admin = Admin::create([ 'name' => $request['name'], 'email' => $request['email'], 'password' => Hash::make($request['password']), ]); return redirect()->intended('login/admin'); } protected function createManager(Request $request) { $this->validator($request->all())->validate(); $manager = Manager::create([ 'name' => $request['name'], 'email' => $request['email'], 'password' => Hash::make($request['password']), ]); return redirect()->intended('login/manager'); } }
function validator()in yourRegisterControllerclass?