首页 文章

laravel 5验证问题

提问于
浏览
0

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

我有这样的回应:

personne.php第10行中的FatalErrorException:找不到类'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

    您需要导入Eloquent Model类:

    use Illuminate\Database\Eloquent\Model;
    
    class personne extends Model implements UserInterface, RemindableInterface {
    // ...
    

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

    您正在使用Laravel 5.1,所以这里是您使用雄辩模型的方式:Eloquent Doc

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

  • 0

    答案是 :

    class '人物'必须从以下开始:

    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;
    

    并且现在一切正常 . 多米尼克

相关问题