【发布时间】:2016-01-23 07:30:49
【问题描述】:
我正在尝试创建一个重置密码 URI,它在那里并使用 Laravel 内置的重置密码系统,但是当我测试它时,我得到:
EloquentUserProvider.php 第 126 行中的 FatalErrorException:类 '\App\User' 未找到
这是我的配置/auth.php:
/*
|--------------------------------------------------------------------------
| Authentication Model
|--------------------------------------------------------------------------
|
| When using the "Eloquent" authentication driver, we need to know which
| Eloquent model should be used to retrieve your users. Of course, it
| is often just the "User" model but you may use whatever you like.
|
*/
'model' => App\User::class,
这是我的 app/Http/routes.php:
/*
|--------------------------------------------------------------------------
| Application Routes
|--------------------------------------------------------------------------
|
| Here is where you can register all of the routes for 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::post('register', 'RegisterController@register');
Route::post('resetpassword', 'Auth\PasswordController@postEmail');
Route::resource('api/authenticate', 'AuthenticateController', ['only' => ['index']]);
Route::post('api/authenticate', 'AuthenticateController@authenticate');
//All protected routes should go in this group
Route::group(['middleware' => 'isUserAuthed'], function () {
Route::get('restricted', 'WelcomeController@welcome');
});
我的用户类位于 app/User.php:
<?php
namespace App;
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 = ['name', 'username', 'password', 'role', 'active', 'email'];
/**
* The attributes excluded from the model's JSON form.
*
* @var array
*/
protected $hidden = ['password', 'remember_token'];
}
有人能指出我正确的方向吗?这方面的文档对我来说似乎不是很清楚。
【问题讨论】:
-
嗯,您是否将默认的
User模型移到了其他地方?默认情况下,它就在app目录下。 -
你在
app/User.php有什么? -
我已将其添加到上述问题中。它位于 app/User.php。