> ## Documentation Index
> Fetch the complete documentation index at: https://docs.rocky.global/llms.txt
> Use this file to discover all available pages before exploring further.

# Management fees

# Management Fees Feature

## Description

This feature allows organizers to configure who pays the management fees associated with their events. Organizers can have fees configured with different types (fixed amount, percentage, or combined), and this feature allows them to decide whether the participant or the organizer absorbs these costs.

## Implemented Features

### 1. Database

* **New fields in the `eventos` table:**
  * `management_fees_config`: JSON for additional configuration
  * `participant_pays_fees`: Boolean (true if the participant pays)
  * `organizer_pays_fees`: Boolean (true if the organizer pays)

### 2. Evento Model

* Added the new fields to `$fillable` and `$casts`
* `getOrganizerTariffConfig()` method to retrieve the organizer's fee configuration

### 3. Controller

* `ManagementFeesController` with methods:
  * `index()`: Shows the current configuration
  * `update()`: Updates the configuration
  * Access permission validation

### 4. Views

* Main view at `resources/views/eventos/config/management_fees/index.blade.php`
* Shows the organizer's fee configuration
* Form to configure who pays the fees
* Integration with the existing navigation system

### 5. Routes

* `GET events/config/management-fees/{id}`: View configuration
* `PUT events/config/management-fees/{id}/update`: Update configuration

## How to Use

### For Organizers

1. **Access the configuration:**
   * Go to the event edit page
   * In the side menu, expand the "Configuration" section
   * Click on "Management Fees" (below "Taxes")

2. **View organizer configuration:**
   * The view automatically shows the fees configured for the organizer
   * Includes type, amount, percentage, period, and status

3. **Configure who pays:**
   * Select between "Participant" or "Organizer"
   * Add additional configuration if needed
   * Save the changes

### For Developers

#### Accessing the configuration programmatically:

```php theme={null}
$evento = Evento::find($id);

// Check who pays the fees
$participantPays = $evento->participant_pays_fees;
$organizerPays = $evento->organizer_pays_fees;

// Get the organizer's fee configuration
$organizerTariff = $evento->getOrganizerTariffConfig();

// Additional configuration
$additionalConfig = $evento->management_fees_config;
```

#### Applying the fee logic:

```php theme={null}
if ($evento->participant_pays_fees) {
    // The participant pays the management fees
    $totalFee = $organizerTariff->total_price;
    if ($organizerTariff->percentage) {
        $totalFee += ($amount * $organizerTariff->percentage / 100);
    }
    // Apply the fee to the participant
} else {
    // The organizer absorbs the fees
    // Do not charge additional fees to the participant
}
```

## File Structure

```
app/
├── Http/Controllers/Eventos/
│   └── ManagementFeesController.php
├── Models/
│   └── Evento.php (updated)

resources/views/eventos/config/management_fees/
└── index.blade.php

database/migrations/
└── 2025_10_08_021356_add_management_fees_to_eventos_table.php

routes/
└── eventos.php (updated)
```

## Validations

* Only organizers and administrators can access
* Validation that at least one option is selected
* Data type validation for the boolean fields

## Technical Notes

* The fields are mutually exclusive (only one can be true)
* The configuration is saved in JSON format for flexibility
* Full integration with the existing navigation system
* Compatible with the existing fee system
* Accessible from the event configuration side menu
