Laravel Auth 自定義user 模型目錄結構
阿新 • • 發佈:2018-12-17
使用自帶的Auth , 如果自定義模型, 需要修改
- config/auth.php
'providers' => [ 'users' => [ 'driver' => 'eloquent', 'model' => App\Models\User::class, # 修改位置 ], // 'users' => [ // 'driver' => 'database', // 'table' => 'users', // ], ],
- config/services.php
'stripe' => [ 'model' => App\Models\User::class, # 修改位置 'key' => env('STRIPE_KEY'), 'secret' => env('STRIPE_SECRET'), ],
- database/factories/UserFactory.php
$factory->define(App\Models\User::class, function (Faker $faker) { # 修改位置 return [ 'name' => $faker->name, 'email' => $faker->unique()->safeEmail, 'password' => '$2y$10$TKh8H1.PfQx37YgCzwiKb.KjNyWgaHb9cbcoQgdIVFlYg7B77UdFm', // secret 'remember_token' => str_random(10), ]; });