首页 文章

Laravel 5.1 Auth :: user()

提问于
浏览
0

我正在将我当前的应用程序升级到laravel框架,我有一个用户和密码的现有数据库 .

我已将用户模型连接到正确的表,并且我还将其中一个用户的密码更新为bcrypt,以便我可以测试登录 .

登录工作正常,并按照您的预期重定向到仪表板,但是,每当我尝试返回Auth :: user()时,我什么都没得到?

这是我的auth模型:

<?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 = 'existing_users_table';

    /**
     * The attributes that are mass assignable.
     *
     * @var array
     */
    protected $fillable = ['email', 'password'];

    /**
     * The attributes excluded from the model's JSON form.
     *
     * @var array
     */
    protected $hidden = ['password'];
}

1 回答

  • 0

    可能您的会话域存在问题 . 你能检查一下你的域名是否有会话?

相关问题