AdminUsersTableSeeder.php 495 B

123456789101112131415161718192021
  1. <?php
  2. use App\Models\AdminUser;
  3. use Illuminate\Database\Seeder;
  4. class AdminUsersTableSeeder extends Seeder
  5. {
  6. public function run()
  7. {
  8. factory(AdminUser::class, 10)->create();
  9. // 整一个用户名为 admin 的用户
  10. if (!$admin = AdminUser::query()->where('username', 'admin')->first()) {
  11. $admin = AdminUser::query()->first();
  12. }
  13. $admin->update([
  14. 'username' => 'admin',
  15. 'name' => '超管',
  16. ]);
  17. }
  18. }