Я новичок в Laravel. хочу использовать свойство redirectTo в моем пользовательском контроллере после регистрации. регистрация работает нормально, но перенаправление не работает
Мой пользовательский контроллер
namespace App\Http\Controllers\Auth\Login;
use Illuminate\Support\Facades\Auth;
use App\Http\Controllers\Auth\LoginController as DefaultLoginController;
use App\Employee;
use App\Http\Controllers\Controller;
use App\Providers\RouteServiceProvider;
class EmployeeController extends Controller
{
protected $redirectTo = RouteServiceProvider::HOME;
public function __construct()
{
$this->middleware('guest:employee')->except('logout');
}
protected function guard()
{
return Auth::guard('employee');
}
public function register()
{
return Employee::create(['employee_id'=>12, 'employee_password'=>2]);
}
}
я добавил провайдеров в моей конфигурации / Auth. php
<?php
return [
'defaults' => [
'guard' => 'web',
'passwords' => 'users',
'passwords' => 'employee',
],
'guards' => [
'web' => [
'driver' => 'session',
'provider' => 'employee',
],
'api' => [
'driver' => 'token',
'provider' => 'employee',
'hash' => false,
],
'employee' => [
'redirectTo' => 'employee.home',
'driver' => 'session',
'provider' => 'employee',
],
],
'providers' => [
'users' => [
'driver' => 'eloquent',
'model' => App\User::class,
],
'employee' => [
'driver' => 'eloquent',
'model' => App\Employee::class,
],
],
'passwords' => [
'users' => [
'provider' => 'users',
'table' => 'password_resets',
'expire' => 60,
'throttle' => 60,
],
'employee' => [
'provider' => 'employee',
'table' => 'password_resets',
'expire' => 60,
],
],
'password_timeout' => 10800,
];
и мой класс Employee в папке приложения
<?php
namespace App;
use Illuminate\Contracts\Auth\MustVerifyEmail;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable;
use Illuminate\Database\Eloquent\Model;
class Employee extends Authenticatable
{
use Notifiable;
protected $fillable = ['employee_id', 'employee_password'];
];
protected $hidden = [
'password', 'remember_token',
];
protected $casts = [
'email_verified_at' => 'datetime',
];
public $timestamps = false;
}
мое промежуточное ПО RedirectIfAuthenticated
<?php
namespace App\Http\Middleware;
use App\Providers\RouteServiceProvider;
use Closure;
use Illuminate\Support\Facades\Auth;
class RedirectIfAuthenticated
{
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @param string|null $guard
* @return mixed
*/
public function handle($request, Closure $next, $guard = null)
{
if (Auth::guard($guard)->check()) {
return redirect(RouteServiceProvider::HOME);
}
return $next($request);
}
}
перенаправление по-прежнему не работает. Чего мне не хватает? Дайте мне знать, если мне не хватает кода для показа