# MyKOPKB 1.0 – Guide

Welcome to **MyKOPKB 1.0**, the streamlined training deployment setup using **Docker**, **Laravel**, and **Vite**.

---

## 🔐 Login Credentials

> Use the following to log into the system:

- **Email**: `isml.msrn11@gmail.com`
- **Password**: `TOPAZTHEGOAT`

---


## Laravel command to clear
```bash
sail artisan config:clear
sail artisan cache:clear
sail artisan permission:cache-reset
```

---

# 🎯 Addtional Notes to consider
- Make sure `/var/www/public/build` exists inside your PHP-FPM container (handled by Dockerfile).
- Assets are built via Vite in the **Node.js stage** and injected into the Laravel `public/` directory.
- Use `entrypoint.sh` for Laravel setup like `php artisan migrate` or `storage:link` if needed.
- 'DEVELOPER' roles can bypassed all permissions by default and cannot be deleted even through database
- Use delete in controller not directly in routes because no authorization and validation
- Use Gate for non-model-specific permissions. general-purpose or simple logic,
- Use policy when need structured authorization for CRUD operations. anything tied to a model/resource
- Servisibility always higher than siapsiaga
- Solution — put specific routes first before resource routes
- to use soft delete, make id and deleted_at as unique 

# Nwidart Command
- to make new module, run:
```bash
sail artisan module:make Example
```
- create migration in module
```bash
sail artisan module:make-migration add_more_details_to_users_table User
```

## Run specific laravel migration:
- If it is fresh, then run:
```bash
sail artisan migrate --path=database/migrations/2025_07_30_044653_create_historical_pkj_perjawatan_table.php
```

- If not, rollback first:
```bash
sail artisan migrate:rollback --step=1

sail artisan migrate --path=database/migrations/2025_07_30_044708_create_historical_pkj_pegangan_status_table.php
```

## To remove data in postgres and restart numbering
```bash
TRUNCATE TABLE kjc_spare_parts RESTART IDENTITY;
```

## Reset query numbering
```sql
SELECT pg_get_serial_sequence('"permissions"', 'id') AS seq_name;
SELECT last_value FROM public.permissions_id_seq;
SELECT setval('public.permissions_id_seq', COALESCE((SELECT MAX(id) FROM permissions), 0) + 1, false);
```

---

# Git
## DO NOT RUN THIS BECAUSE IT WILL REMOVE ALL THE UNTAGGED FILES IN LOCAL
```bash
git reset --hard development # moves the current branch (e.g., main) to point exactly where development
```