61 lines
1.6 KiB
PHP
61 lines
1.6 KiB
PHP
<?php
|
|
|
|
namespace Database\Seeders;
|
|
|
|
use Carbon\Carbon;
|
|
use App\Models\User;
|
|
use Illuminate\Database\Seeder;
|
|
use Illuminate\Support\Facades\Hash;
|
|
use Illuminate\Support\Facades\Log;
|
|
use Illuminate\Support\Facades\Schema;
|
|
use Illuminate\Support\Str;
|
|
use Exception;
|
|
|
|
class UsersTableSeeder extends Seeder
|
|
{
|
|
/**
|
|
* Run the database seeds.
|
|
*
|
|
* @return void
|
|
*/
|
|
public function run()
|
|
{
|
|
try {
|
|
|
|
Schema::disableForeignKeyConstraints();
|
|
|
|
User::truncate();
|
|
|
|
$admin = [
|
|
'uuid' => Str::uuid(),
|
|
'name' => 'Admin',
|
|
'email' => 'admin@globaljain.com',
|
|
'email_hash' => 'admin@globaljain.com',
|
|
'password' => Hash::make('Admin@123'),
|
|
'username' => 'Admin',
|
|
'mobile' => NULL,
|
|
'dharma_id' => NULL,
|
|
'email_verified_at' => now(),
|
|
'mobile_verified_at' => now(),
|
|
'avatar' => '',
|
|
'verification_confirmed' => 2,
|
|
'status' => 2,
|
|
'timezone' => '',
|
|
'last_login_at' => NULL,
|
|
'last_login_ip' => '',
|
|
'remember_token' => '',
|
|
'created_at' => Carbon::now()->format('Y-m-d H:i:s'),
|
|
'updated_at' => Carbon::now()->format('Y-m-d H:i:s'),
|
|
'deleted_at' => NULL,
|
|
];
|
|
|
|
$user = User::create($admin);
|
|
$user->assignRole(1);
|
|
|
|
Schema::enableForeignKeyConstraints();
|
|
} catch (Exception $ex) {
|
|
Log::error($ex->getMessage());
|
|
}
|
|
}
|
|
}
|