Changing Laravel authenticate model

Results 1 to 5 of 5
  1. #1
    Registered briian is offline
    MemberRank
    May 2017 Join Date
    8Posts

    Changing Laravel authenticate model


    RaGEZONE Recommends

    RaGEZONE Recommends

    Hey all,

    I was trying to find how to change the authenticatable model in Laravel to use `Player` instead (model I have made but haven't touched yet) but all of the resources I have found online are for past versions of laravel. Has anyone done this and has a good resource for it?

    excuse any typos im tired as hell.

    thanks


  2. #2
    You Can't Deal With it Bola is offline
    DeveloperRank
    Dec 2011 Join Date
    BrazilLocation
    1,483Posts

    Re: Changing Laravel authenticate model

    in version 5.4 with multi auth

    if you're looking to add a new auth without change default one

    duplicate this following line in auth.php inside config from laravel package

    Code:
    'web' => [ // RENAME WEB TO A NEW GUARD SERVICE
                'driver' => 'session',
                'provider' => 'users', // PLACE HERE THE USER PROVIDER NAME
            ],
    also duplicate this following line
    Code:
            'users' => [ // CHANGE TO A NEW USER PROVIDER NAME
                'driver' => 'eloquent',
                'model' => App\Models\User::class, // CHANGE TO A MODEL THAT EXTENDS FROM AUTHENTICATE CLASS 
            ],
    then you can create your authentication service in the guard using Auth::guard('newguardname')->attempt([ 'login' => 'alooo', 'password' => 'md5encodedstring'], false);

  3. #3
    Registered briian is offline
    MemberRank
    May 2017 Join Date
    8Posts

    Re: Changing Laravel authenticate model

    I'm fine with changing the default one, I don't think I'll need it, right? The db will need to access the players table, never users.

  4. #4
    ◝(⁰▿⁰)◜Formerly CodeDragon ◝(⁰▿⁰)◜ Taiga is offline
    ModeratorRank
    May 2007 Join Date
    InternetLocation
    2,385Posts

    Re: Changing Laravel authenticate model

    You can change the table name by adding an override to the $table property in the users model.
    You could just add:
    Code:
    public $table = 'Players';
    Moderator & Developer
    I CAN NOT HELP YOU WITH YOUR SERVER, USE THE CORRECT HELP SECTION INSTEAD.


    DO NOT PM ME FOR GAME RELATED QUESTIONS, THESE MESSAGES WILL BE IGNORED!

    The Rules | Discord | MMORPG Extra | Contact Me


  5. #5
    Registered briian is offline
    MemberRank
    May 2017 Join Date
    8Posts

    Re: Changing Laravel authenticate model

    hoping that works taiga




Advertisement