# UAE Travel System - Installation Guide

## Project Updated: Complete Laravel 11 Setup

This project has been updated with all necessary Laravel framework files including:
- ✅ composer.json with Laravel 11 and all dependencies
- ✅ Complete Laravel directory structure
- ✅ Bootstrap files and configuration
- ✅ Storage directories with proper structure
- ✅ Test structure
- ✅ Artisan command-line tool
- ✅ Updated .env configuration for Laravel 11
- ✅ Package.json for frontend assets
- ✅ All required configuration files

## Prerequisites

- **PHP**: >= 8.2 (Laravel 11 requirement)
- **Composer**: Latest version
- **MySQL**: 5.7+ or MariaDB 10.3+
- **Node.js**: >= 18.x (for frontend assets)
- **XAMPP**: Already installed on your system

## Installation Steps

### 1. Verify PHP Version

```powershell
php -v
```

Make sure you're running PHP 8.2 or higher. If not, update XAMPP or install PHP 8.2+.

### 2. Install Composer Dependencies

The dependencies have already been installed. If you need to reinstall:

```powershell
cd d:\xampp\htdocs\uae-travel-system
composer install
```

### 3. Configure Environment

The `.env` file has been updated with Laravel 11 requirements. Update these values:

```env
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=uae_system
DB_USERNAME=root
DB_PASSWORD=your_mysql_password
```

### 4. Generate Application Key

```powershell
php artisan key:generate
```

### 5. Create Database

Open MySQL/phpMyAdmin and create the database:

```sql
CREATE DATABASE uae_system CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
```

Or if you have a database dump file mentioned in the README:

```powershell
mysql -u root -p uae_system < database/uae_travel_system.sql
```

### 6. Run Database Migrations

If importing the SQL dump, verify migrations:

```powershell
php artisan migrate:status
```

If starting fresh:

```powershell
php artisan migrate --seed
```

### 7. Install API Routes

Laravel 11 ships with API routes disabled by default. Enable them:

```powershell
php artisan install:api
```

### 8. Set Up Storage

Create the symbolic link for public storage:

```powershell
php artisan storage:link
```

### 9. Install Frontend Dependencies (Optional)

```powershell
npm install
npm run build
```

For development with hot reload:

```powershell
npm run dev
```

### 10. Configure Mail (for lead notifications)

Update in `.env`:

```env
MAIL_MAILER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=587
MAIL_USERNAME=your-email@gmail.com
MAIL_PASSWORD=your-app-specific-password
MAIL_ENCRYPTION=tls
MAIL_FROM_ADDRESS="your-email@gmail.com"
LEAD_NOTIFY_EMAIL=your-email@gmail.com
```

For Gmail, you need to create an App Password: https://myaccount.google.com/apppasswords

### 11. Set Permissions (if on Linux/Mac)

```bash
chmod -R 775 storage bootstrap/cache
```

### 12. Run the Application

Start the development server:

```powershell
php artisan serve
```

Visit: http://localhost:8000

## Admin Dashboard

To access the admin pricing dashboard:

1. **Login URL**: http://localhost:8000/admin/login
2. **Default Credentials**:
   - Email: `admin@dextratechnologies.com`
   - Password: `ChangeMe123!`

⚠️ **IMPORTANT**: Change the default admin password before production:

```powershell
php artisan tinker
```

Then run:

```php
User::where('email','admin@dextratechnologies.com')->update(['password' => Hash::make('your_new_password')]);
exit
```

## API Endpoints

The application exposes these main API endpoints:

- `GET /api/meta` - Bootstrap data (Emirates, currencies, interests)
- `POST /api/trip-plans` - Create new trip plan
- `GET /api/trip-plans/{id}/recommend` - Get AI recommendations
- `POST /api/trip-plans/{id}/calculate-cost` - Calculate trip cost
- `POST /api/trip-plans/{id}/send-quote` - Send quote via email

## Troubleshooting

### Issue: "Class not found" errors

Solution:
```powershell
composer dump-autoload
```

### Issue: "Permission denied" on storage

Solution (Windows):
- Right-click `storage` folder → Properties → Security → Edit
- Give full control to your user

### Issue: Database connection failed

Solution:
- Verify MySQL is running in XAMPP
- Check database credentials in `.env`
- Make sure database exists

### Issue: "419 Page Expired" on forms

Solution:
- Clear cache: `php artisan cache:clear`
- Clear config: `php artisan config:clear`
- Clear views: `php artisan view:clear`

### Issue: Assets not loading

Solution:
```powershell
npm run build
php artisan optimize:clear
```

## Production Deployment

Before deploying to production:

1. ✅ Change `APP_ENV=production` in `.env`
2. ✅ Set `APP_DEBUG=false` in `.env`
3. ✅ Generate new `APP_KEY`: `php artisan key:generate --force`
4. ✅ Change admin password
5. ✅ Update `APP_URL` to your domain
6. ✅ Set real database password
7. ✅ Configure real mail credentials with App Password
8. ✅ Run optimizations:
   ```powershell
   composer install --optimize-autoloader --no-dev
   php artisan config:cache
   php artisan route:cache
   php artisan view:cache
   ```

## Additional Commands

```powershell
# Clear all caches
php artisan optimize:clear

# Run tests
php artisan test

# Check routes
php artisan route:list

# Check database status
php artisan migrate:status

# Run code style fixer
./vendor/bin/pint

# Open tinker (Laravel REPL)
php artisan tinker
```

## Support

For issues specific to this installation, check:
- Laravel 11 documentation: https://laravel.com/docs/11.x
- Project README.md for business logic details

## What's Included

This complete Laravel 11 installation includes:

✅ All framework files and dependencies
✅ Database models and migrations
✅ API controllers for all modules
✅ Admin authentication and pricing dashboard
✅ Email notification system for leads
✅ AI recommendation engine
✅ Cost calculator service
✅ Multi-currency support
✅ PDF generation for quotes
✅ Complete frontend views

The application is now ready for development and deployment!
