拉拉维尔的自定义登录系统


Custom Login System In Laravel

我在Laravel中创建了一个自定义登录系统。

这是我的控制器:

<?php
namespace App'Http'Controllers;
use App'User;
use Illuminate'Support'Facades'Auth;
class Front extends Controller
{
    public function register()
    {
        if (Request::isMethod('post')) {
            User::create([
                'name' => Request::get('name'),
                'email' => Request::get('email'),
                'password' => bcrypt(Request::get('password')),
            ]);
        }
        return Redirect::away('login');
    }
    public function authenticate()
    {
        if (Auth::attempt(['email' => Request::get('email'), 'password' => Request::get('password')])) {
            return redirect()->intended('checkout');
        } else {
            return view('login', array('title' => 'Welcome', 'description' => '', 'page' => 'home'));
        }
    }
    public function login()
    {
        return view('auth/login', array('page' => 'home'));
    }
    public function checkout()
    {
        return view('/aboutme', array('page' => 'home'));
    }
}

路线是:

// Authentication routes...
Route::get('auth/login', 'Front@login');
Route::post('auth/login', 'Front@authenticate');
Route::get('auth/logout', 'Front@logout');
// Registration routes...
Route::post('/register', 'Front@register');
Route::get('/checkout', [
    'middleware' => 'auth',
    'uses' => 'Front@checkout'
]);

我得到的错误是:

致命错误前面的异常.php第 12 行:类 找不到"应用程序''http''控制器''请求"

您需要导入请求。将其添加到控制器的顶部:

use Request;

顺便说一下,您还需要为Redirect立面执行此操作。

导入应如下所示:

use Auth;
use Request;
use Redirect;
use App'Http'Controllers'Controller;

尝试以下操作,因为您似乎没有在Front Controller中使用请求特定的命名空间:

use Illuminate'Http'Request;