/database/seeds/Access/UserTableSeeder.php
https://gitlab.com/Ankit77/motiv8 · PHP · 55 lines · 44 code · 6 blank · 5 comment · 8 complexity · 40704fc29754e72178dc1186bb1c3cd7 MD5 · raw file
- <?php
- use Carbon\Carbon as Carbon;
- use Illuminate\Database\Seeder;
- use Illuminate\Support\Facades\DB;
- /**
- * Class UserTableSeeder
- */
- class UserTableSeeder extends Seeder
- {
- public function run()
- {
- if (env('DB_CONNECTION') == 'mysql') {
- DB::statement('SET FOREIGN_KEY_CHECKS=0;');
- }
- if (env('DB_CONNECTION') == 'mysql') {
- DB::table(config('access.users_table'))->truncate();
- } elseif (env('DB_CONNECTION') == 'sqlite') {
- DB::statement('DELETE FROM ' . config('access.users_table'));
- } else {
- //For PostgreSQL or anything else
- DB::statement('TRUNCATE TABLE ' . config('access.users_table') . ' CASCADE');
- }
- //Add the master administrator, user id of 1
- $users = [
- [
- 'name' => 'Admin',
- 'email' => 'info@webdevelopmentpark.com',
- 'password' => bcrypt('123456'),
- 'confirmation_code' => md5(uniqid(mt_rand(), true)),
- 'confirmed' => true,
- 'created_at' => Carbon::now(),
- 'updated_at' => Carbon::now(),
- ],
- [
- 'name' => 'Anil Jain',
- 'email' => 'aniljmk@gmail.com',
- 'password' => bcrypt('123456'),
- 'confirmation_code' => md5(uniqid(mt_rand(), true)),
- 'confirmed' => true,
- 'created_at' => Carbon::now(),
- 'updated_at' => Carbon::now(),
- ],
- ];
- DB::table(config('access.users_table'))->insert($users);
- if (env('DB_CONNECTION') == 'mysql') {
- DB::statement('SET FOREIGN_KEY_CHECKS=1;');
- }
- }
- }