Один раз я могу зайти на localhost:8000/auth/register у меня открывается форма регистрации, я ввожу данные и пользователь появляется в моей базе и все, больше я не могу зайти на localhost:8000/auth/register что бы завести еще одного пользователя, меня перебрасывает на localhost:8000 либо выбрасывает NotFoundHttpException in RouteCollection.php line 161:
Вот мой код, что не так?
routes.php
<?php
/*
|--------------------------------------------------------------------------
| Routes File
|--------------------------------------------------------------------------
|
| Here is where you will register all of the routes in an application.
| It's a breeze. Simply tell Laravel the URIs it should respond to
| and give it the controller to call when that URI is requested.
|
*/
Route::get('/', function () {
return view('welcome');
});
/*
|--------------------------------------------------------------------------
| Application Routes
|--------------------------------------------------------------------------
|
| This route group applies the "web" middleware group to every route
| it contains. The "web" middleware group is defined in your HTTP
| kernel and includes session state, CSRF protection, and more.
|
*/
Route::group(['middleware' => ['web']], function () {
// Registration routes...
Route::get('auth/register', 'Auth\AuthController@getRegister');
Route::post('auth/register', 'Auth\AuthController@postRegister');
});
AuthController.php
<?php
namespace App\Http\Controllers\Auth;
use App\Models\User;
use Validator;
use App\Http\Controllers\Controller;
use Illuminate\Foundation\Auth\ThrottlesLogins;
use Illuminate\Foundation\Auth\AuthenticatesAndRegistersUsers;
class AuthController extends Controller
{
/*
|--------------------------------------------------------------------------
| Registration & Login Controller
|--------------------------------------------------------------------------
|
| This controller handles the registration of new users, as well as the
| authentication of existing users. By default, this controller uses
| a simple trait to add these behaviors. Why don't you explore it?
|
*/
use AuthenticatesAndRegistersUsers, ThrottlesLogins;
/**
* Where to redirect users after login / registration.
*
*
var string
*/
protected $redirectTo = '/home';
/**
* Create a new authentication controller instance.
*
*
return void
*/
public function __construct()
{
$this->middleware('guest', ['except' => 'logout']);
}
/**
* Get a validator for an incoming registration request.
*
* @param array $data
*
return \Illuminate\Contracts\Validation\Validator
*/
protected function validator(array $data)
{
return Validator::make($data, [
'first_name' => 'required|alpha',
'last_name' => 'required|alpha',
'email_address' => 'required|email|unique:users,email_address',
'password' => 'required|min:6',
]);
}
/**
* Create a new user instance after a valid registration.
*
* @param array $data
*
return User
*/
protected function create(array $data)
{
return User::create([
'first_name' => $data['first_name'],
'last_name' => $data['last_name'],
'email_address' => $data['email_address'],
'password' => bcrypt($data['password']),
]);
}
}
User.php
<?php namespace App\Models;
use Illuminate\Auth\Authenticatable;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Auth\Passwords\CanResetPassword;
use Illuminate\Foundation\Auth\Access\Authorizable;
use Illuminate\Contracts\Auth\Authenticatable as AuthenticatableContract;
use Illuminate\Contracts\Auth\Access\Authorizable as AuthorizableContract;
use Illuminate\Contracts\Auth\CanResetPassword as CanResetPasswordContract;
class User extends Model implements AuthenticatableContract, AuthorizableContract, CanResetPasswordContract {
use Authenticatable, Authorizable, CanResetPassword;
/**
* The database table used by the model.
*
*
var string
*/
protected $table = 'users';
/**
* The attributes that are mass assignable.
*
*
var array
*/
protected $fillable = ['first_name', 'last_name', 'email_address', 'skype_name', 'password'];
/**
* The attributes excluded from the model's JSON form.
*
*
var array
*/
protected $hidden = ['password', 'role_id', 'remember_token'];