Perbaikan modul data karyawan dan staff + modul SOP import
This commit is contained in:
@@ -3,23 +3,35 @@
|
||||
namespace Database\Seeders;
|
||||
|
||||
use App\Models\User;
|
||||
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
|
||||
use Illuminate\Database\Seeder;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
use Spatie\Permission\Models\Role;
|
||||
|
||||
class DatabaseSeeder extends Seeder
|
||||
{
|
||||
use WithoutModelEvents;
|
||||
|
||||
/**
|
||||
* Seed the application's database.
|
||||
*/
|
||||
public function run(): void
|
||||
{
|
||||
// User::factory(10)->create();
|
||||
// 1. Bersihkan Cache Spatie
|
||||
app()[\Spatie\Permission\PermissionRegistrar::class]->forgetCachedPermissions();
|
||||
|
||||
User::factory()->create([
|
||||
'name' => 'Test User',
|
||||
'email' => 'test@example.com',
|
||||
]);
|
||||
// 2. Buat Role Baku
|
||||
$roleAdmin = Role::firstOrCreate(['name' => 'admin', 'guard_name' => 'web']);
|
||||
Role::firstOrCreate(['name' => 'trainer', 'guard_name' => 'web']);
|
||||
|
||||
// 3. Patenkan Akun Utama Anda
|
||||
$user = User::updateOrCreate(
|
||||
['email' => 'iwit@tia-pharma.com'],
|
||||
[
|
||||
'first_name' => 'Iwit',
|
||||
'last_name' => 'Admin',
|
||||
'password' => Hash::make('rahasia1234'), // Password baku permanen
|
||||
'is_active' => 1,
|
||||
'must_change_password' => 0,
|
||||
'email_verified_at' => now(),
|
||||
]
|
||||
);
|
||||
|
||||
// 4. Otomatis Jadikan Admin
|
||||
$user->assignRole($roleAdmin);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user