Permalink
Find file
45588b2 Jan 7, 2017
@rappasoft @helmerdavila @vjandrea
70 lines (63 sloc) 2.33 KB
<?php
use Carbon\Carbon as Carbon;
use Illuminate\Database\Seeder;
use Illuminate\Support\Facades\DB;
/**
* Class UserTableSeeder.
*/
class UserTableSeeder extends Seeder
{
/**
* Run the database seed.
*
* @return void
*/
public function run()
{
if (DB::connection()->getDriverName() == 'mysql') {
DB::statement('SET FOREIGN_KEY_CHECKS=0;');
}
if (DB::connection()->getDriverName() == 'mysql') {
DB::table(config('access.users_table'))->truncate();
} elseif (DB::connection()->getDriverName() == '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 Istrator',
'email' => 'admin@admin.com',
'password' => bcrypt('1234'),
'confirmation_code' => md5(uniqid(mt_rand(), true)),
'confirmed' => true,
'created_at' => Carbon::now(),
'updated_at' => Carbon::now(),
],
[
'name' => 'Backend User',
'email' => 'executive@executive.com',
'password' => bcrypt('1234'),
'confirmation_code' => md5(uniqid(mt_rand(), true)),
'confirmed' => true,
'created_at' => Carbon::now(),
'updated_at' => Carbon::now(),
],
[
'name' => 'Default User',
'email' => 'user@user.com',
'password' => bcrypt('1234'),
'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 (DB::connection()->getDriverName() == 'mysql') {
DB::statement('SET FOREIGN_KEY_CHECKS=1;');
}
}
}