Support the ongoing development of Laravel.io →
posted 9 years ago
Architecture

I whant change defaule auth table -- users,

//    migartions/2014_10_12_000000_create_users_table.php

/**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('godruoyi_admin_user', function (Blueprint $table) {
            $table->increments('id');
            $table->string('nickname');
            $table->string('username')->unique();
            $table->string('email')->unique();
            $table->string('password');
            $table->rememberToken();
            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::drop('godruoyi_admin_user');
    }

AuthController.php

/**
     * Get a validator for an incoming registration request.
     *
     * @param  array  $data
     * @return \Illuminate\Contracts\Validation\Validator
     */
    protected function validator(array $data)
    {
        return Validator::make($data, [
            'name' => 'required|max:255',
            'email' => 'required|email|max:255|unique:users',
            'password' => 'required|min:6|confirmed',
            'nickname' => 'required|max:255',
        ]);
    }

    /**
     * Create a new user instance after a valid registration.
     *
     * @param  array  $data
     * @return User
     */
    protected function create(array $data)
    {
        return User::create([
            'username' => $data['name'],
            'email' => $data['email'],
            'nickname' => $data['nickname'],
            'password' => bcrypt($data['password']),
        ]);
    }

config/auth.php

'providers' => [
        'users' => [
            'driver' => 'eloquent',
            'model' => App\User::class,
            'table' => 'godruoyi_admin_user',
        ],

        // 'users' => [
        //     'driver' => 'database',
        //     'table' => 'users',
        // ],
    ],

User model php file

/**
     * The attributes that are mass assignable.
     *
     * @var array
     */
    protected $fillable = [
        'username', 'email', 'password', 'nickname'
    ];


    /**
     * The database table used by the model.
     *
     * @var string
     */
    protected $table = 'godruoyi_admin_user';

    /**
     * The attributes that should be hidden for arrays.
     *
     * @var array
     */
    protected $hidden = [
        'password', 'remember_token',
    ];

SO, I whant change default auth table ---users to godruoyi_admin_user, but it's no success,

Last updated 3 years ago.
0

dddddddddddddddddddddd

0

Can you post the exact error that you get..??

0

Sign in to participate in this thread!

Eventy

Your banner here too?

godruoyi godruoyi Joined 5 May 2016

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2025 Laravel.io - All rights reserved.