# Contributing

## Prerequisites

- PHP 8.2+
- Composer 2.x
- Node.js 20+ / npm 10+
- MySQL or MariaDB (via XAMPP or standalone)
- Git

## Setup

```bash
git clone <repo-url> C:\radiology-ris
cd C:\radiology-ris

# Install PHP dependencies
composer install

# Install JS dependencies
npm install

# Environment
copy .env.example .env
# Edit .env: DB_DATABASE=radiology_ris, DB_USERNAME=root, DB_PASSWORD=

# Generate key
php artisan key:generate

# Database
php artisan migrate
php artisan db:seed --class=DatabaseSeeder

# Storage link
php artisan storage:link

# Compile frontend
npm run build

# Serve
php artisan serve
```

## Development Workflow

1. Create feature branch from main
2. Make changes following CODING_STANDARDS.md
3. Run `npm run build` after any SCSS/JS changes
4. Test manually via browser at `http://127.0.0.1:8000`
5. Verify seeded users work: `dr.oziris` / `password` (admin)
6. Commit with descriptive message
7. Push and open PR

## Adding a New Permission

1. Add to `database/seeders/RolesAndPermissionsSeeder.php`
2. Run `php artisan db:seed --class=RolesAndPermissionsSeeder`
3. Assign permission to relevant roles in the seeder
4. Add `permission:new_permission` middleware to route(s) in `routes/web.php`
5. Run seeder again to assign

## Adding a New Module

1. Create migration for any new table
2. Create Model with relationships
3. Create Controller (singular PascalCase)
4. Register routes in `routes/web.php` with auth + permission middleware
5. Create views extending `layouts.adminlte`
6. Add menu link in sidebar (`layouts/adminlte.blade.php`)
7. Run `php artisan migrate`

## Code Review Checklist

- [ ] Follows coding standards (PHP 8.2 typed, eager loading, no raw SQL)
- [ ] Routes properly guarded with `auth` + `permission` middleware
- [ ] Views extend `layouts.adminlte` and use Font Awesome icons
- [ ] No N+1 queries (check with Laravel Debugbar or manual review)
- [ ] Validation rules comprehensive
- [ ] CSRF protection on all POST/PUT/DELETE forms
- [ ] No hardcoded URLs or secrets
- [ ] `npm run build` passes without errors
