laravel 5验证问题

时间:2015-12-31 11:30:10

标签: php laravel-5.1

我的身份验证系统不起作用(使用laravel 5.1)。你能帮我么 ?我是Laravel的初学者,当然我忘记了什么,但我不知道是什么。

我有这样的回应:

   personne.php第10行中的FatalErrorException:Class   找不到“App \ Models \ Eloquent”

我的auth.php:

 'driver' => 'eloquent',

/*
|--------------------------------------------------------------------------
| 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,
    'model' => 'App\Models\personne',

我的人物类:

 namespace App\Models;
use Illuminate\Auth\Authenticatable;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Auth\Passwords\CanResetPassword;
use Illuminate\Contracts\Auth\Authenticatable as AuthenticatableContract;
use Illuminate\Contracts\Auth\CanResetPassword as CanResetPasswordContract;

class personne extends Eloquent implements UserInterface, RemindableInterface {


    protected $table = 'personne';
    protected $primaryKey = 'id_personne';
    public $timestamps = false; // pour ne pas que laravel update lui même les champs dates de la table


    public function getReminderEmail()
    {
        return $this->email;
    }

etc....

我的控制器:

    namespace App\Http\Controllers;

use Illuminate\Support\Facades\Validator;
use Illuminate\Support\Facades\Input;
use Auth;

class AuthentificationController extends Controller {

编辑: 我改变了这样的人物类:

    namespace App\Models;
use Eloquent;
use Illuminate\Auth\Authenticatable;
use Illuminate\Database\Eloquent\Model;

use Illuminate\Auth\Passwords\CanResetPassword;
use Illuminate\Contracts\Auth\Authenticatable as AuthenticatableContract;
use Illuminate\Contracts\Auth\CanResetPassword as CanResetPasswordContract;


class personne extends Model implements UserInterface, RemindableInterface {

现在错误是:

personne.php第13行中的FatalErrorException:未找到接口'App \ Models \ UserInterface'

2 个答案:

答案 0 :(得分:0)

您需要导入Eloquent Model类:

use Illuminate\Database\Eloquent\Model;

class personne extends Model implements UserInterface, RemindableInterface {
// ...

请尊重OOP指令并使用大写字母作为您班级名称中的第一个字母Personne

您正在使用Laravel 5.1,以便您使用雄辩的模型:Eloquent Doc

您可以使用Laravel提供的开箱即用的身份验证系统Here

答案 1 :(得分:0)

答案是:

班级' personne'必须从:

开始
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 Personne extends Model implements AuthenticatableContract,
                                    AuthorizableContract,
                                    CanResetPasswordContract

{
    use Authenticatable, Authorizable, CanResetPassword;

现在一切正常。 多米尼克