Laravel 5.1 Auth :: user()

时间:2016-04-27 12:22:09

标签: php laravel laravel-5 eloquent

我正在将当前的应用程序升级到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 :(得分:0)

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