# VIP Fan Card Dynamic Pricing Setup

## Overview
The VIP Fan Card system has been updated to support dynamic pricing that can be managed by admins. Admins can now create, edit, and delete fan card plans with custom pricing, benefits, and features.

## Installation Steps

### 1. Run the Migration
```bash
php artisan migrate
```
This will create the `fan_card_plans` table.

### 2. Seed Initial Plans (Optional)
```bash
php artisan db:seed --class=FanCardPlanSeeder
```
This will create three default plans:
- **Silver**: $99/year (10% discount on bookings)
- **Gold**: $199/year (15% discount on bookings) - Featured
- **Platinum**: $399/year (25% discount on bookings)

## Admin Management

### Accessing Fan Card Plans
Navigate to: **Admin Dashboard → VIP Fan Card Plans**
URL: `/admin/dashboard/fan-card-plans`

### Features

#### 1. View All Plans
- See all created fan card plans
- View plan details including price, benefits, and status
- See which plan is featured (recommended)
- Check active/inactive status

#### 2. Create New Plan
- Plan Name (e.g., Silver, Gold, Diamond)
- Annual Price
- Description
- Discount Percentage (for celebrity bookings)
- Badge Color (gray, yellow, purple, blue, green, red)
- Icon (star, crown, award, gem, shield)
- Benefits (multiple items)
- Sort Order (display order)
- Active Status (visible to users)
- Featured Status (recommended plan)

#### 3. Edit Existing Plan
- Update all plan details
- Add/remove benefits
- Change pricing
- Toggle active/featured status

#### 4. Delete Plan
- Delete plans that have no active bookings
- System prevents deletion of plans with existing bookings

#### 5. Toggle Status
- Quickly activate/deactivate plans
- Inactive plans are hidden from users but preserved in database

## User Experience

### Booking Flow
1. User clicks "Fan Card" button on celebrity page
2. System displays all **active** fan card plans from database
3. Plans show:
   - Plan name
   - Annual price
   - Description
   - Discount percentage
   - Benefits (if any)
   - Featured badge (if applicable)
4. User selects a plan and proceeds with booking
5. System calculates:
   - Plan price (from database)
   - Processing fee: $9.95
   - Total amount

### Dynamic Display
- Plans are pulled from database in real-time
- Ordered by `sort_order` then by `price`
- Only active plans are shown to users
- Featured plan is pre-selected by default
- Benefits are displayed dynamically

## Database Schema

### Table: `fan_card_plans`
- `id` - Primary key
- `name` - Plan name (Silver, Gold, etc.)
- `slug` - URL-friendly identifier
- `price` - Annual membership price
- `description` - Plan description
- `benefits` - JSON array of benefits
- `discount_percentage` - Booking discount %
- `is_active` - Visibility status
- `is_featured` - Recommended plan flag
- `sort_order` - Display order
- `badge_color` - UI color theme
- `icon` - Icon name
- `created_at` / `updated_at`

## Files Created/Modified

### New Files:
1. `database/migrations/2026_01_04_000000_create_fan_card_plans_table.php`
2. `app/Models/FanCardPlan.php`
3. `app/Http/Controllers/Admin/FanCardPlanController.php`
4. `resources/views/admin/fan_card_plans/index.blade.php`
5. `resources/views/admin/fan_card_plans/create.blade.php`
6. `resources/views/admin/fan_card_plans/edit.blade.php`
7. `database/seeders/FanCardPlanSeeder.php`

### Modified Files:
1. `app/Http/Controllers/BookingController.php`
   - Updated `showBookingForm()` to fetch plans
   - Updated `processFanCard()` to use dynamic pricing
   - Updated validation rules

2. `resources/views/home/booking.blade.php`
   - Dynamic tier selection rendering
   - Dynamic benefits display
   - Updated JavaScript for dynamic pricing

3. `routes/admin/web.php`
   - Added fan card plan management routes

## Benefits System

Benefits are stored as a JSON array and can include any text. Examples:
- Priority booking access
- Digital/Physical fan card
- Discount percentages
- Exclusive content access
- Birthday messages
- Meet & greet opportunities
- Community access
- Newsletter subscription

## Notes

### Processing Fee
The $9.95 processing fee is currently hardcoded but can be made dynamic by:
1. Adding a `processing_fee` field to settings table
2. Or creating a separate config table

### Plan Deletion Protection
- Plans with existing bookings cannot be deleted
- System checks booking count before deletion
- Admin sees error message if deletion is blocked

### Booking Reference Format
Fan card bookings use prefix: `FAN-XXXXXXXX`

### Discount Application
The `discount_percentage` field is stored but not automatically applied. To implement:
1. Check user's active fan card membership
2. Apply discount at booking time
3. Show discounted price in booking summary

## Testing

### Test the System:
1. Create a new fan card plan in admin
2. Go to a celebrity page
3. Click "Fan Card" button
4. Verify new plan appears in the list
5. Select the plan and complete booking
6. Check booking details show correct plan and pricing

### Verify Admin Functions:
- Create plan
- Edit plan
- Toggle active status
- Try to delete plan with bookings (should fail)
- Delete plan without bookings (should succeed)

## Future Enhancements

Potential features to add:
- Bulk import plans
- Plan analytics (most popular, revenue by plan)
- Automatic discount application for members
- Membership renewal reminders
- Tiered benefits unlock system
- Member-only content access
- Integration with loyalty points system
