mercredi 27 avril 2016

Laravel 5.1 Auth::user()

I am upgrading my current application to a laravel framework, I have an existing database of users and passwords.

I have connected the user model to the right table, and I've also updated the password of one of the users to bcrypt so I can test the log in.

The log in works fine and redirects to the dashboard as you'd expect, however, whenever I try to return the Auth::user() I get nothing?

Here's my auth model:

<?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'];
}



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/1pEStah
via IFTTT

Aucun commentaire:

Enregistrer un commentaire