app/Http/Controllers/Auth/RegisterController.php
/**
     * Get a validator for an incoming registration request.
     *
     * @param  array  $data
     * @return \Illuminate\Contracts\Validation\Validator
     */
Get a validator for an incoming registration request.
@param  array  $data
@return \Illuminate\Contracts\Validation\Validator
Get a validator for an incoming registration request . @param array $data @return \ Illuminate \ Contracts \ Validation \ Validator
protected function validator(array $data)
    {
        if (in_array($data['type'] , ['super_admin' , 'company'])) {
            return Validator::make($data, [
                'name' => ['required', 'string', 'max:255'],
                'email' => ['required', 'string', 'email', 'max:255', 'unique:users'],
                'type' => ['required', 'string'],
                'phone' => ['required', 'string', 'max:255', 'unique:users'],
                'address' => ['required', 'string', 'max:255'],
                'password' => ['required', 'string', 'min:8', 'confirmed'],
            ]);
        }
        else{
        return Validator::make($data, [
            'name' => ['required', 'string', 'max:255'],
            'email' => ['required', 'string', 'email', 'max:255', 'unique:users'],
            'type' => ['required', 'string'],
            'phone' => ['required', 'string', 'max:255', 'unique:users'],
            'address' => ['required', 'string', 'max:255'],
            'password' => ['required', 'string', 'min:8', 'confirmed'],
            'code' => ['required', 'string', 'digits:4', 'exists:users'],
        ]);
    }
}
protected function validator ( array $ data ) { if ( in_array ( $ data [ 'type' ] , [ 'super_admin' , 'company' ] ) ) { return Validator :: make ( $ data , [ 'name' => [ 'required' , 'string' , 'max:255' ] , 'email' => [ 'required' , 'string' , 'email' , 'max:255' , 'unique:users' ] , 'type' => [ 'required' , 'string' ] , 'phone' => [ 'required' , 'string' , 'max:255' , 'unique:users' ] , 'address' => [ 'required' , 'string' , 'max:255' ] , 'password' => [ 'required' , 'string' , 'min:8' , 'confirmed' ] , ] ) ; } else { return Validator :: make ( $ data , [ 'name' => [ 'required' , 'string' , 'max:255' ] , 'email' => [ 'required' , 'string' , 'email' , 'max:255' , 'unique:users' ] , 'type' => [ 'required' , 'string' ] , 'phone' => [ 'required' , 'string' , 'max:255' , 'unique:users' ] , 'address' => [ 'required' , 'string' , 'max:255' ] , 'password' => [ 'required' , 'string' , 'min:8' , 'confirmed' ] , 'code' => [ 'required' , 'string' , 'digits:4' , 'exists:users' ] , ] ) ; } }
Get a validator for an incoming registration request.
Get a validator for an incoming registration request .