# fluent-support/2.2.1/app/Http/Controllers/WidgetsController.php

Fluent Support – Helpdesk &amp; Customer Support Ticket System, version 2.2.1. 59 lines.

- Page: https://pluginprobe.com/plugins/fluent-support/2.2.1/code/app/Http/Controllers/WidgetsController.php
- Raw: https://pluginprobe.com/plugins/fluent-support/2.2.1/raw/app/Http/Controllers/WidgetsController.php
- Modified: 2026-04-09T13:48:06+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/fluent-support/2.2.1/code/app/Http/Controllers/WidgetsController.php#L10-L20`.

```php
<?php

namespace FluentSupport\App\Http\Controllers;

use FluentSupport\App\Models\Ticket;
use FluentSupport\Framework\Http\Request\Request;

class WidgetsController extends Controller
{
    public function __invoke(Request $request)
    {
        $filter = $request->get('filter', '');
        $filter = sanitize_text_field($filter);
        $filter = str_replace('fluent_support_', '', $filter);

        // Only allow alphanumeric, underscores, and hyphens in filter names
        if (!$filter || !preg_match('/^[a-zA-Z0-9_\-]+$/', $filter)) {
            return $this->sendError([
                'message' => __('Invalid filter name', 'fluent-support')
            ]);
        }

        $data = $request->get('data', []);

        if (!is_array($data)) {
            $data = [];
        }

        // Sanitize all scalar values in data
        $data = array_map(function ($value) {
            return is_scalar($value) ? sanitize_text_field($value) : $value;
        }, $data);

        if ($filter === 'ticket_sidebar') {
            $ticketId = intval($data['ticket_id'] ?? 0);
            if (!$ticketId) {
                return $this->sendError([
                    'message' => __('Invalid ticket ID', 'fluent-support')
                ]);
            }

            $ticket = Ticket::with('customer')->find($ticketId);
            if (!$ticket) {
                return $this->sendError([
                    'message' => __('Ticket not found', 'fluent-support')
                ]);
            }

            $this->ensureCanAccessTicket($ticket);

            $data['ticket'] = $ticket;
        }

        return $this->sendSuccess([
            'widgets' => apply_filters('fluent_support/widgets/' . $filter, [], $data)
        ]);
    }
}

```
