first commit
This commit is contained in:
61
database/seeders/UserSeeder.php
Normal file
61
database/seeders/UserSeeder.php
Normal file
@@ -0,0 +1,61 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use App\Models\Consultant;
|
||||
use App\Models\User;
|
||||
use Illuminate\Database\Seeder;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
|
||||
class UserSeeder extends Seeder
|
||||
{
|
||||
public function run(): void
|
||||
{
|
||||
$users = [
|
||||
['name' => 'Super Admin', 'email' => 'superadmin@mbip.gov.my', 'role' => 'Super Admin', 'jawatan' => 'Pentadbir Sistem'],
|
||||
['name' => 'JPP Admin', 'email' => 'jppadmin@mbip.gov.my', 'role' => 'JPP Admin', 'jawatan' => 'Pentadbir JPP'],
|
||||
['name' => 'Pegawai JPP', 'email' => 'pegawai@mbip.gov.my', 'role' => 'Pegawai JPP', 'jawatan' => 'Pegawai Perancang Bandar'],
|
||||
['name' => 'Penolong Pegawai JPP', 'email' => 'penolong@mbip.gov.my', 'role' => 'Penolong Pegawai', 'jawatan' => 'Penolong Pegawai Perancang Bandar'],
|
||||
['name' => 'Kerani JPP', 'email' => 'kerani@mbip.gov.my', 'role' => 'Kerani', 'jawatan' => 'Pembantu Tadbir'],
|
||||
];
|
||||
|
||||
foreach ($users as $data) {
|
||||
$user = User::firstOrCreate(
|
||||
['email' => $data['email']],
|
||||
[
|
||||
'name' => $data['name'],
|
||||
'password' => Hash::make('password'),
|
||||
'jawatan' => $data['jawatan'],
|
||||
'is_active' => true,
|
||||
'email_verified_at' => now(),
|
||||
]
|
||||
);
|
||||
$user->syncRoles([$data['role']]);
|
||||
}
|
||||
|
||||
// Akaun perunding contoh + profil perunding berkait.
|
||||
$perundingUser = User::firstOrCreate(
|
||||
['email' => 'perunding@example.com'],
|
||||
[
|
||||
'name' => 'Perunding Contoh Sdn Bhd',
|
||||
'password' => Hash::make('password'),
|
||||
'jawatan' => 'Perunding Alam Sekitar',
|
||||
'is_active' => true,
|
||||
'email_verified_at' => now(),
|
||||
]
|
||||
);
|
||||
$perundingUser->syncRoles(['Perunding']);
|
||||
|
||||
Consultant::firstOrCreate(
|
||||
['emel' => 'perunding@example.com'],
|
||||
[
|
||||
'user_id' => $perundingUser->id,
|
||||
'nama_perunding' => 'Perunding Contoh Sdn Bhd',
|
||||
'no_pendaftaran_syarikat' => '202301000123 (1234567-A)',
|
||||
'alamat' => 'No. 1, Jalan Hijau, 81200 Johor Bahru, Johor',
|
||||
'telefon' => '07-1234567',
|
||||
'aktif' => true,
|
||||
]
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user