Laravel 8 Override Auth Register Method

Hello,

Right now, i we are going to present you laravel eight override auth register technique. This text provides you with easy instance of laravel eight override auth register technique. you’ll laravel eight override auth register technique. On this article, we are going to implement a laravel eight override auth register technique.

So let’s observe few step to create instance of laravel eight override auth register technique.

default route for register technique:


Route::get('register', 'AuthRegisterController@showRegistrationForm')->identify('register');
Route::submit('register', 'AuthRegisterController@register');

app/Http/Controllers/Auth/RegisterController.php


<?php
  
namespace AppHttpControllersAuth;
  
use AppHttpControllersController;
use AppProvidersRouteServiceProvider;
use AppModelsUser;
use IlluminateFoundationAuthRegistersUsers;
use IlluminateSupportFacadesHash;
use IlluminateSupportFacadesValidator;
  
class RegisterController extends Controller
{
    /*
    |--------------------------------------------------------------------------
    | Register Controller
    |--------------------------------------------------------------------------
    |
    | This controller handles the registration of recent customers in addition to their
    | validation and creation. By default this controller makes use of a trait to
    | present this performance with out requiring any extra code.
    |
    */
  
    use RegistersUsers;
  
    /**
     * The place to redirect customers after registration.
     *
     * @var string
     */
    protected $redirectTo = RouteServiceProvider::HOME;
  
    /**
     * Create a brand new controller occasion.
     *
     * @return void
     */
    public operate __construct()
    {
        $this->middleware('visitor');
    } 
  
    /**
     * Write code on Methodology
     *
     * @return response()
     */
    public operate showRegistrationForm()
    {
        return view('register');
    }
  
    /**
     * Write code on Methodology
     *
     * @return response()
     */
    public operate register(Request $request)
    {
        $this->validator($request->all())->validate();
  
        $this->create($request->all());
  
        return redirect("dashboard");
    }
  
    /**
     * Get a validator for an incoming registration request.
     *
     * @param  array  $knowledge
     * @return IlluminateContractsValidationValidator
     */
    protected operate validator(array $knowledge)
    {
        return Validator::make($knowledge, [
            'name' => ['required', 'string', 'max:255'],
            'e-mail' => ['required', 'string', 'email', 'max:255', 'unique:users'],
            'password' => ['required', 'string', 'min:8', 'confirmed'],
        ]);
    }
  
    /**
     * Create a brand new person occasion after a legitimate registration.
     *
     * @param  array  $knowledge
     * @return AppModelsUser
     */
    protected operate create(array $knowledge)
    {
        return Consumer::create([
            'name' => $data['name'],
            'e-mail' => $knowledge['email'],
            'password' => Hash::make($knowledge['password']),
        ]);
    }
}

I hope it’ll help you…

Komentar

Postingan populer dari blog ini

PHP 8 Multiple Select Dropdown Example

Laravel 8 Get HTTP Hostname

JQuery Drag And Drop Menu Example