'Trying to Register Multiple user via Default laravel Auth

I have 3 users

Customer Restaurant Rider

Am trying to register the rider via default routes so I can login again:

<form method="POST" action="{{ route('register') }}">
        @csrf

        <h4 class="text-light-black fw-600">Create your account</h4>

        <input type="text" name="type" value="rider">

        <div class="row">

            <div class="col-lg-6 col-md-12 col-sm-6">
                <div class="form-group">
                    <label class="text-light-white fs-14">First name</label>
                    <input type="text" name="first_name" class="form-control form-control-submit"
                           placeholder="First Name" required>
                </div>
            </div>
            <div class="col-lg-6 col-md-12 col-sm-6">
                <div class="form-group">
                    <label class="text-light-white fs-14">Last name</label>
                    <input type="text" name="last_name" class="form-control form-control-submit" placeholder="Last Name"
                           required>
                </div>
            </div>


            <div class="col-lg-6 col-md-12 col-sm-6">
                <div class="form-group">
                    <label class="text-light-white fs-14">Username</label>
                    <input type="text" name="username" class="form-control form-control-submit" placeholder="Username"
                           required>
                </div>
            </div>
            <div class="col-lg-6 col-md-12 col-sm-6">
                <div class="form-group">
                    <label class="text-light-white fs-14">CNIC</label>
                    <input type="text" name="cnic" class="form-control form-control-submit" placeholder="CNIC" required>
                </div>
            </div>


            <div class="col-lg-6 col-md-12 col-sm-6">
                <div class="form-group">
                    <label class="text-light-white fs-14">Ride Number</label>
                    <input type="text" name="ride_number" class="form-control form-control-submit"
                           placeholder="Ride Number" required>
                </div>
            </div>
            <div class="col-lg-6 col-md-12 col-sm-6">
                <div class="form-group">
                    <label class="text-light-white fs-14">Ride Chassis</label>
                    <input type="text" name="chassis_number" class="form-control form-control-submit"
                           placeholder="Ride Chassis" required>
                </div>
            </div>

            <div class="col-lg-6 col-md-12 col-sm-6">
                <div class="form-group">
                    <label class="text-light-white fs-14">Password</label>
                    <input type="password" name="password" class="form-control form-control-submit"
                           placeholder="Password" required>
                </div>
            </div>
            <div class="col-lg-6 col-md-12 col-sm-6">
                <div class="form-group">
                    <label class="text-light-white fs-14">Confirm Password</label>
                    <input type="password" name="password_confirmation" class="form-control form-control-submit"
                           placeholder="Confirm Password" required>
                </div>
            </div>


            <div class="col-12">

                <div class="form-group">
                    <label class="text-light-white fs-14">Email</label>
                    <input type="email" name="email" class="form-control form-control-submit" placeholder="Email I'd" required>
                </div>

                <div class="form-group">
                    <label class="text-light-white fs-14">Address</label>
                    <input type="text" name="address" class="form-control form-control-submit" placeholder="Address" required>
                </div>

                <div class="form-group">
                    <button type="submit" class="btn-second btn-submit full-width">Create your account</button>
                </div>


                <div class="form-group text-center"></div>
                <span class="text-light-black fs-12 terms">By creating your Munchbox account, you agree to the <a
                        href="#"> Terms of Use </a> and <a href="#"> Privacy Policy.</a></span>
            </div>
        </div>

    </form>

Here's is my the create method

protected function create(array $data) { dd($data);

if ($data['type']=='rider')
{
    $user= Rider::create([
        'first_name' => $data['first_name'],
        'last_name' => $data['last_name'],
        'password' => Hash::make($data['password']),
        'address' => $data['address'],
    ]);

}else
    {
        $user = User::create([
            'name' => $data['name'],
            'password' => Hash::make($data['password']),
            'email' => $data['email'],
        ]);
    }

return $user;

}

what am trying to do is when a new rider wants to register themself he can, so he can also use the default login laravel routes and methods

but am failed to do that the page refresh on the same page and the rider doesn't register in the rider table.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source