# SkillLake backend

Features live in `modules/{name}` as Composer path packages (`skill-lake/{name}`, `SkillLake\{Name}`). Match coding practices in `course`, `book`, `event`, and `learning-path` — do not invent structure.

## Modules

- Scaffold providers and package registration from `modules/course/composer.json`. Follow `CourseServiceProvider` for routes, middleware, and swagger.
- Developer HTML tools stay in `routes/api.developer.php`.

## Code

- Prefer static functions that return lists (`types()`, `contentTypes()`) over class constant arrays.
- Use readable, self-explanatory names for variables and functions. Do not use generic names like `$data`, `$item`, `getData()`, or `processItem()`; specify what they are (`$courseData`, `$bookItem`, `getCourseData()`, `processBookItem()`). Do not use unnecessary short forms (`$bspi`, `$spi`, `$primary`, `getBspi()`); spell the meaning out (`$bookStructurePrimaryId`, `getBookStructurePrimaryId()`).
- Keep code easy to read and maintain. Do not use PHP variable variables (`$$name`) or other dynamic-variable indirection; use explicit names, arrays, or `match`/`switch` instead. Prefer straightforward logic over clever or compact patterns.

## Requests

- Validate every request input, including allowed keys, type, length (`max:` / `size:`), and enums. Do not read unvalidated `$request` fields.
- For larger forms, use an explicit FormRequest class.

## Database

- Tables are `upskill_{snake}` via `FingentTableNamingConvention`. New migrations go in app `database/migrations/`. Create them with `php artisan make:migration` (or a `Y_m_d_His` prefix).
- Use `auth()->user()->id`, not `auth()->id`, for `created_by` / `updated_by`.
- Wrap writes in `DB::beginTransaction()` / `DB::commit()` / `DB::rollBack()` (see course and learning-path repositories). Do not use `DB::transaction()`.
