Home > Back-end >  retrieve database values in register page in laravel
retrieve database values in register page in laravel

Time:10-21

I have registration auth in laravel project and i need some existing datas should show up on the registration form , please guide me up..

http://165.232.187.63/register

This is my register page and i need to fetch existing database values in the registration form. for example

    <select>
@foreach($users as $items) 
      <option>{{ $items->id }}</option>
@endforeach
    </select>

How to customize this...

I have tried adding in web.php file

Route::get('/register','App\Http\Controllers\Auth\UserController@index');

And in my UserController.php

   public function index()
{
    $users = User::all();
    return view('auth.register')
           ->with('users', $users);
}

But can't use both post and get for register auth

CodePudding user response:

You need to use separate endpoints for this task one to load the view

Route::get('/register','App\Http\Controllers\Auth\UserController@index');

and the other to do the actual registration

Route::post('/register','App\Http\Controllers\Auth\UserController@register');

of course in the UserController, you will have a register method that handles the actual registration process

  • Related