# REDD+ Dev Project Knowledge

## Project Structure
- **Laravel app** at `C:\laragon\www\dynaweb4\dev new\redd-plus-dev`
- **Database**: MySQL, configured in `.env`
- **Admin panel**: Tailadmin theme, CSS at `public/tailadmin/src/css/style.css`

## Frontend Theme (REDD+ portal)
CSS variables defined in: `database/seeders/redd-plus/ReddPlusSiteLayoutSeeder.php`
```
--green-900: #22392a
--green-800: #2e4a35
--green-700: #3d5c44
--green-200: #cddac9
--green-100: #e4ecdf
--gold: #b9975b
--cream: #f7f5ee (body background)
--ink: #3a4a3f (text color)
--card-bg: #ffffff (card background, recently added)
```

## Info Card Styling
- `.info-card` CSS is embedded inline in article content stored in DB
- Defined in seeders:
  - `database/seeders/redd-plus/ReddPlusArticleSeeder.php` (articles with info-card HTML)
  - `database/seeders/redd-plus/ReddPlusPageSeeder.php` (pages with info-card HTML)
- Also in cached view files under `storage/framework/views/` (auto-regenerated)
- Recent update (2026-07-29): strengthened card with white bg, stronger border `#d8d4c8`, added `box-shadow`

## Database Tables
- `content_article` - articles (PK: `article_id`)
- `content_article_translation` - translations including HTML content (`article_translation_content`)
- `theme_rules` / `theme_settings` - dynamic theme configuration
- `settings` - key-value app settings (sidebar colors, etc.)
- `data_dashboard` - dashboard widgets
- `frontend_sites` - site layouts (header, footer, layout HTML)

## Key Models
- `app/Models/Backend/ContentArticle.php` - article model, hasMany translations
- `app/Models/Backend/ContentArticleTranslation.php` - translation model
- `app/Models/Backend/ThemeSetting.php` / `ThemeRule.php` - theme config
- `app/Models/Backend/Setting.php` - key-value settings
- `app/Models/Backend/FrontendSite.php` - frontend sites

## Article ID Mapping & Translation Lookup
- URL `?id=<article_code>` maps to `content_article.article_code`.
- Translation rows are linked by `content_article_translation.article_translation_parent_id` → `content_article.article_id`.
- Not all articles have both `en` and `ms` translations. The frontend may fall back to whichever translation exists.

### Current Key Article IDs (ephemeral — verify before hard-coding)
> These IDs change whenever seeders are refreshed or content is re-imported; always query `content_article` for the current value.

| `article_code` | `article_id` | Current translations (`article_translation_id`, language) | Notes |
|---|---|---|---|
| `national-redd-strategy` | `51` | `116` (`en`) | Style reference for info-card / hero-article layout |
| `forest-governance` | `69` | `167` (`en`) | `ms` translation not currently present |
| `stakeholder-engagement` | `49` | `146` (`en`) | |
| `governance` | `50` | `113` (`en`) | |

### Quick lookup snippet
```bash
php artisan tinker --execute="$a = App\Models\Backend\ContentArticle::where('article_code', 'forest-governance')->with('translations')->first(); dd($a->toArray());"
```

## Content Editing Notes
- Article content is full HTML stored in `content_article_translation.article_translation_content`.
- Custom article styles (e.g., `.feature-card`, `.stake-card`, `.info-card`) are embedded as inline `<style>` blocks inside the article content.
- Summernote editors (contentArticle + contentPhotoGallery create/edit blades) use a custom `codeviewFilterRegex` that keeps `<style>` tags but still strips `<script>` on Code View toggle / paste. Do NOT remove this config or inline `<style>` blocks will be silently deleted on save. The default Summernote regex strips both.
- `<style>` entities: Code View shows `>` as `&gt;` in text nodes (normal innerHTML serialization, display-only, no data loss).
- WYSIWYG preview: frontend theme CSS variables (`--green-800`, `--gold`, etc.) are re-declared scoped to `.note-editable` in `public/vendor/summernote/summernote-tailadmin.css` so article colors resolve in the admin editor. Keep in sync with `ReddPlusSiteLayoutSeeder.php` if variables change.
- Some images in article content are hosted externally (`https://redd.nres.gov.my/wp-content/uploads/...`).
- After editing article content, run `php artisan cache:clear` and `php artisan view:clear` to refresh the rendered page.

## Tinker Tips
- When using `php artisan tinker --execute="..."`, use single backslashes for namespaces: `App\Models\Backend\ContentArticle`.
- Do not double-escape backslashes (`\\`) in the execute argument.

## Key Controllers
- `app/Http/Controllers/Backend/ContentArticleController.php` - article CRUD

## Helpers
- `app/Http/Helpers/SettingHelper.php` - `get()`/`set()` for settings with cache
- `app/Helpers/DashboardHelper.php` - `render()` for dashboard widgets

## Migrations
- Article tables: `2026_05_13_142707_create_content_article_table.php`, `2026_05_13_142708_create_content_article_translation_table.php`
- Theme: `2026_07_01_000001_create_theme_tables.php`
- Settings: `2026_06_18_154226_create_settings_table.php`
- Dashboard: `2026_05_21_045007_create_data_dashboard_table.php`
