mardi 23 février 2016

Authentication in Laravel 5.1.11 - it keeps using default 'User' model and searching 'users' tab

I've created a custom user model, with a custom protected $table name. But the attempt method in the controller keeps searching and using the default one ('User' model and 'users' tab) The weird part is that in Laravel 5.2 it works. Maybe it's just me that I've missed a stupid thing, but why does it not work on 5.1? Thanks for your time.

Model:

namespace App;
use Illuminate\Database\Eloquent\Model;

class CustomUser extends Model
{
    protected $table ='myuserstab';
}

Controller:

namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Http\Requests;
use App\Http\Controllers\Controller;
use Auth;
use App\CustomUser;

class loginController extends Controller
{

    public function login(Request $request)
    {

        $nomeutente = $request['username'];
        $password = $request['password'];
        if(Auth::attempt(['username'=>$username, 'password'=>$password]))
        {
          doSomething...
        }
        else 
        {
         doSomethingelse...
        }
    }
...
}



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire