# XRD LAB Website (Laravel 11)

This project is the public website and admin panel for **XRD LAB**.

It includes:
- Public Arabic website pages (home, about, services, blog/news, contact, hiring, legal pages)
- Blog/article reading with comments and optional audio playback
- Filament admin dashboard for managing content
- Media uploads (images, audio, files) stored in `storage/app/public`
- SQLite database by default (tracked in this repository)

## Tech Stack

- PHP 8.2+
- Laravel 11
- Filament 3
- Blade views (public frontend)
- Vite / Tailwind tooling (available for asset build pipeline)

## Local Development

1. Install dependencies:
```bash
composer install
npm install
```

2. Create environment file:
```bash
cp .env.example .env
php artisan key:generate
```

3. Database setup (SQLite default):
```bash
touch database/database.sqlite
php artisan migrate --force
```

4. Link public storage:
```bash
php artisan storage:link
```

5. Run app:
```bash
php artisan serve
```

## Apache Deployment (Production)

### 1) Server requirements
- Apache 2.4+
- PHP 8.2+ with required Laravel extensions
- Composer

Enable Apache modules:
```bash
sudo a2enmod rewrite headers
sudo systemctl restart apache2
```

### 2) Deploy code
```bash
cd /var/www
git clone <your-repo-url> xrdlab-laravel
cd xrdlab-laravel
composer install --no-dev --optimize-autoloader
npm install
npm run build
```

### 3) Environment and app key
```bash
cp .env.example .env
php artisan key:generate --force
```

Update at minimum in `.env`:
- `APP_ENV=production`
- `APP_DEBUG=false`
- `APP_URL=https://your-domain.com`
- DB settings (`sqlite` or MySQL/MariaDB)

If using SQLite:
```bash
touch database/database.sqlite
```

### 4) Migrate and cache
```bash
php artisan migrate --force
php artisan storage:link
php artisan config:cache
php artisan route:cache
php artisan view:cache
```

### 5) File permissions
Set web server write access for:
- `storage/`
- `bootstrap/cache/`
- (if SQLite) `database/database.sqlite`

Example:
```bash
sudo chown -R www-data:www-data storage bootstrap/cache database
sudo chmod -R 775 storage bootstrap/cache
sudo chmod 664 database/database.sqlite
```

### 6) Apache VirtualHost
Set document root to Laravel `public/`:

```apache
<VirtualHost *:80>
    ServerName your-domain.com
    ServerAlias www.your-domain.com
    DocumentRoot /var/www/xrdlab-laravel/public

    <Directory /var/www/xrdlab-laravel/public>
        AllowOverride All
        Require all granted
    </Directory>

    ErrorLog ${APACHE_LOG_DIR}/xrdlab-error.log
    CustomLog ${APACHE_LOG_DIR}/xrdlab-access.log combined
</VirtualHost>
```

Then:
```bash
sudo a2ensite your-site.conf
sudo systemctl reload apache2
```

## Notes

- Uploaded media is in `storage/app/public/...`.
- Public symlink is `public/storage`.
- Database files are tracked in this repo, including `database/database.sqlite`.
