samedi 5 octobre 2019

User registration error in Laravel. Anyone help me?

Can anyone help me with this error? I am making an application, I am using the Laravel Framework version 5.8.35.

ERROR :

Argument 1 passed to App\Http\Controllers\Auth\RegisterController::validator() must be an instance of Illuminate\Http\Request

Register Controller :

The idea of ​​control is to control the sending of data between the view and the database. This controller controls the application's remit.

<?php

namespace App\Http\Controllers\Auth;

use App\User;
use App\Http\Controllers\Controller;
use Illuminate\Foundation\Auth\RegistersUsers;
use Illuminate\Http\Request;

class RegisterController extends Controller
{

    use RegistersUsers;


    protected $redirectTo = '/home';


    public function __construct()
    {
        $this->middleware('guest');
    }


    protected function validator(Request $request)
    {
        $this ->validate($request, [
        'nome' => 'required|max:255',
        'sobrenome' => 'required|max:255',
        'email' => 'required|email|unique:users,email|max:255',
        'cpf' => 'required|min:11|unique:users,cpf',
        'rg' => 'required|min:7|unique:users,rg',
        'telefone' => 'required',
        'celular' => 'required',
        'rua' => 'required|max:255',
        'bairro' => 'required|max:255',
        'complemento' => 'max:255',
        'numero' => 'required',
        'cep' => 'required|min:8',
        'datanascimento' => 'required|date|before:today',
        'password' => 'required|min:8|confirmed|max:60',
        ]);


        $user = User::create(request(['nome','sobrenome', 'email','cpf','rg','telefone','celular','rua','bairro','complento','numero','cep','datanascimento','password']));

        auth()->login($user);

        return redirect()->to('/home');


    }

}

View Register:

The idea of ​​the view is to show the user in a friendlier way how to register to use the system.

    @section('content')

<link href="" rel="stylesheet">


            <div class="form-horizontal">
                

                <div class="form-group">
                    
                    
                    @if ($errors->has('nome'))
                        
                    @endif
                </div>

                <div class="form-group">
                    
                    
                    @if ($errors->has('nome'))
                        
                    @endif
                </div>

                <div class="form-group">
                    
                    
                    @if ($errors->has('datanascimento'))
                        
                    @endif
                </div>

                <div class="form-group">
                    
                    
                    @if ($errors->has('cpf'))
                        
                    @endif
                </div>

                <div class="form-group">
                    
                    
                    @if ($errors->has('rg'))
                        
                    @endif
                </div>

                <div class="form-group">
                    
                    
                    @if ($errors->has('telefone'))
                        
                    @endif
                </div>

                <div class="form-group">
                    
                    
                    @if ($errors->has('celular'))
                        
                    @endif
                </div>

                <div class="form-group">
                    
                    
                    @if ($errors->has('rua'))
                        
                    @endif
                </div>

                <div class="form-group">
                    
                    
                    @if ($errors->has('bairro'))
                        
                    @endif
                </div>

                <div class="form-group">
                    
                    
                    @if ($errors->has('complemento'))
                        
                    @endif
                </div>

                <div class="form-group">
                    
                    
                    @if ($errors->has('numero'))
                        
                    @endif
                </div>

                <div class="form-group">
                    
                    
                    @if ($errors->has('cep'))
                        
                    @endif
                </div>

                <div class="form-group">
                    
                    
                    @if ($errors->has('email'))
                        
                    @endif
                </div>

                <div class="form-group">
                    
                    
                    @if ($errors->has('password'))
                        
                    @endif
                </div>
                <div class="form-group">
                    
                    
                    @if ($errors->has('password_confirmation'))
                        
                    @endif
                </div>

                <div class="form-group">
                    
                    
                    
                </div>
            </div>
        </div>
    </div>
</div>
@endsection


via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire