Voyager: login table

Created on 14 Mar 2017  路  16Comments  路  Source: the-control-group/voyager

  • Laravel Version: 5.4
  • Voyager Version: 11
  • PHP Version:5.6
  • Database Driver & Version:

Description:

@abdgad
how can i make admin login in another table instead of users table
example : i created admins table it's attributes id,email,password i want admin login through this table instead of users table which it is already exits in laravel ??

thanks

Steps To Reproduce:

bug question

All 16 comments

You can specify the table you want to use in the model by adding this:

protected $table = 'admins';

However, I currently don't know the best way to extend Voyager's User model. One way is to do:

class User extends \TCG\Voyager\Models\User
{
    protected $table = 'admins';
}

@marktopper can tell you more information.

The login system uses the Voyager User model in order to login, however you can overwrite this as @abdgad told by creating your own class at:

app/VoyagerUser.php

<?php

namespace App;

class VoyagerUser extends \TCG\Voyager\Models\User
{
    protected $table = 'admins';
}

And then tell Voyager to use that model for the users.

Voyager::useModel('User', \App\VoyagerUser);

thank you so much :)
@abdgad @marktopper

i'm sorry it give me this error

screenshot from 2017-03-14 15-08-49

Can you please update your composer.json file to use dev-use-user-model as version for Voyager.
Then run a composer update and test this out again.

Please let me know wether or not it works, cause then I can merge this in and tag a new release.
Thanks for the report.

@marktopper
i did what u said but give me same problem :(

Okay. Once I get home I will look into this and notice you.

ok thanks for your efforts

Sorry for the delay, have been busy.

ok no problem :)

@marktopper: any progress with this?

I have created a separate SiteEditor user class as per your instructions but still Voyager is using the User model and therefore the users table.

Voyager::useModel('User', \App\Models\SiteEditor::class); has been added to AppServiceProvider::boot().

Same issue as @u01jmg3 above. I am using Laravel 5.4 and cannot get this to work using a different users table called admins. It still tries to use the users table.

@marktopper do you have any suggestions for this?

Any updates with this issue because it would be wonderful if you can separate 'users' table from 'admins' table!

@marktopper solution should work. Close this for now.

This issue has been automatically locked since there has not been any recent activity after it was closed. If you have further questions please ask in our Slack group.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

kevinjon27 picture kevinjon27  路  3Comments

duongsieu picture duongsieu  路  3Comments

zzpwestlife picture zzpwestlife  路  3Comments

vaggelis2018 picture vaggelis2018  路  3Comments

wislem picture wislem  路  3Comments