You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
60 lines
1.3 KiB
60 lines
1.3 KiB
--- |
|
description: Standar backend Laravel untuk geonet-console dan databaselist |
|
globs: geonet-console/**/*.php,databaselist/**/*.php |
|
alwaysApply: false |
|
--- |
|
|
|
# Laravel Backend |
|
|
|
## Struktur |
|
|
|
``` |
|
Controller → Service → Model/Repository |
|
→ AuditLogService (aksi sensitif) |
|
``` |
|
|
|
## Controller |
|
|
|
- Tipis: validasi request + delegasi ke Service |
|
- **Jangan** query Eloquent langsung di controller |
|
- **Jangan** business logic (merge/sort LDAP) di controller |
|
|
|
## Service |
|
|
|
- Semua use case di `app/Services/` |
|
- Log audit via `AuditLogService` untuk CRUD LDAP, DB, SMTP, token |
|
- Secret dari `config()` / `env()`, encrypt password DB dengan `Crypt` |
|
|
|
## API |
|
|
|
- Route prefix `api/v1/` |
|
- Middleware scope + throttle |
|
- Response JSON konsisten; dokumentasi di Swagger UI |
|
- OAuth2 Passport untuk client credentials |
|
|
|
## Database |
|
|
|
- App metadata: PostgreSQL Docker |
|
- Audit log: connection `audit` terpisah |
|
- Koneksi dinamis: `DatabaseConnectionManager` untuk SQL Server, PG, MySQL |
|
|
|
## Perubahan schema |
|
|
|
- Selalu buat migration |
|
- Jangan hapus data tanpa konfirmasi user |
|
|
|
## Contoh delegasi benar |
|
|
|
```php |
|
// ✅ Controller |
|
public function store(StoreRequest $request, LdapUserService $service) |
|
{ |
|
return $service->create($request->validated()); |
|
} |
|
|
|
// ❌ Controller |
|
public function store(Request $request) |
|
{ |
|
LdapUser::query()->where(...)->get(); |
|
} |
|
```
|
|
|