Authentication Can';t使用不同的表进行身份验证

Authentication Can';t使用不同的表进行身份验证,authentication,laravel,laravel-4,Authentication,Laravel,Laravel 4,我更改了auth.php文件,以便根据authors表对用户进行身份验证。但是当我运行testroute时,我一直没有得到你的帐户 auth.php <?php return array( 'driver' => 'eloquent', 'model' => 'Author', 'table' => 'authors', 'reminder' => array( 'email' => 'emails.

我更改了
auth.php
文件,以便根据authors表对用户进行身份验证。但是当我运行
test
route时,我一直没有得到你的帐户

auth.php

<?php

return array(

    'driver' => 'eloquent',

    'model' => 'Author',

    'table' => 'authors',

    'reminder' => array(

        'email' => 'emails.auth.reminder', 'table' => 'password_reminders',

    ),

);
Route::get('test', function() {
    $credentials = array('username' => 'giannis',
        'password' => Hash::make('giannis'));
    if (Auth::attempt($credentials)) {
        return "You are a user.";
    }
    return "No account for you";
});
<?php

class AuthorsTableSeeder extends Seeder {

    public function run()
    {
        // Uncomment the below to wipe the table clean before populating
      DB::table('authors')->delete();

      $authors = array(
         [ 
         'username' => 'giannis',
         'password' => Hash::make('giannis'),
         'name' => 'giannis',
         'lastname' => 'christofakis'],
         [
         'username' => 'antonis',
         'password' => Hash::make('antonis'),
         'name' => 'antonis',
         'lastname' => 'antonopoulos']
         );

        // Uncomment the below to run the seeder
      DB::table('authors')->insert($authors);
  }

}
<?php

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

class Author extends Eloquent implements UserInterface, RemindableInterface {

    protected $guarded = array();

    public static $rules = array();

    public function posts() {
        return $this->hasMany('Post');
    }

    /**
         * Get the unique identifier for the user.
         *
         * @return mixed
         */
    public function getAuthIdentifier()
    {
        return $this->getKey();
    }

    /**
     * Get the password for the user.
     *
     * @return string
     */
    public function getAuthPassword()
    {
        return $this->password;
    }

        /**
     * Get the e-mail address where password reminders are sent.
     *
     * @return string
     */
        public function getReminderEmail()
        {
            return "giannis@hotmail.com";
        }
    }
authorstableeeder.php

<?php

return array(

    'driver' => 'eloquent',

    'model' => 'Author',

    'table' => 'authors',

    'reminder' => array(

        'email' => 'emails.auth.reminder', 'table' => 'password_reminders',

    ),

);
Route::get('test', function() {
    $credentials = array('username' => 'giannis',
        'password' => Hash::make('giannis'));
    if (Auth::attempt($credentials)) {
        return "You are a user.";
    }
    return "No account for you";
});
<?php

class AuthorsTableSeeder extends Seeder {

    public function run()
    {
        // Uncomment the below to wipe the table clean before populating
      DB::table('authors')->delete();

      $authors = array(
         [ 
         'username' => 'giannis',
         'password' => Hash::make('giannis'),
         'name' => 'giannis',
         'lastname' => 'christofakis'],
         [
         'username' => 'antonis',
         'password' => Hash::make('antonis'),
         'name' => 'antonis',
         'lastname' => 'antonopoulos']
         );

        // Uncomment the below to run the seeder
      DB::table('authors')->insert($authors);
  }

}
<?php

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

class Author extends Eloquent implements UserInterface, RemindableInterface {

    protected $guarded = array();

    public static $rules = array();

    public function posts() {
        return $this->hasMany('Post');
    }

    /**
         * Get the unique identifier for the user.
         *
         * @return mixed
         */
    public function getAuthIdentifier()
    {
        return $this->getKey();
    }

    /**
     * Get the password for the user.
     *
     * @return string
     */
    public function getAuthPassword()
    {
        return $this->password;
    }

        /**
     * Get the e-mail address where password reminders are sent.
     *
     * @return string
     */
        public function getReminderEmail()
        {
            return "giannis@hotmail.com";
        }
    }

使用
Auth::trunt()时,不需要散列密码因此从路由中删除
Hash::make

Route::get('test', function() {
$credentials = array('username' => 'giannis',
    'password' => 'giannis');
if (Auth::attempt($credentials)) {
    return "You are a user.";
}
return "No account for you";
}))


它将像一个符咒一样工作

你创建了作者模型吗?@TryingTobemyselfRahul我已经在上面发布了。