Laravel 4 – non-standard username/passwd fields in user auth table

I’ve been doing a lot of development in Laravel 4 these days – just a great, great framework! But I’m learning it has certain expectations as far as naming conventions go. An example would be the way authentication is done via Eloquent (ORM). Eloquent’s default authentication fields are  ‘username’ and ‘password’. If you want to have something different, you need to extend some functions in order to return the information you want:

// app/models/User.php

use Illuminate\Auth\UserInterface;
use Illuminate\Auth\Reminders\RemindableInterface;

class User extends Eloquent implements UserInterface, RemindableInterface {

protected $fillable = array('name','passwd','email','status','timezone','language','notify');
protected $hidden = array('passwd');

protected $table = "users_t";
protected $primaryKey = "uid";

public static $rules = array(
'name' => 'required',
'passwd' => 'required',
'email' => 'required'

public function getAuthIdentifier() {
return $this->getKey();

public function getAuthPassword() {
return $this->passwd;

public function getReminderEmail() {
return $this->email;

public static function validate($data) {
return Validator::make($data,static::$rules);

The key parts are ‘getAuthIdentifier()’ and ‘getAuthPassword()’ – if you notice, I use a non-standard table ‘users_t’ and I use ‘uid’ as the primary key instead of the expected ‘id’. getKey() picks up the $primaryKey variable.