PHP code example of lukehowland / helpdeskwidget

1. Go to this page and download the library: Download lukehowland/helpdeskwidget library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

lukehowland / helpdeskwidget example snippets


// Encabezado de sección
['header' => 'SOPORTE'],

// Elemento del menú
[
    'text' => 'Centro de Soporte',      // Texto que se muestra en el sidebar
    'url' => 'helpdesk',                // Ruta creada por el instalador
    'icon' => 'fas fa-fw fa-headset',   // Icono FontAwesome
],

return [
    // URL del servidor Helpdesk
    'api_url' => env('HELPDESK_API_URL', 'https://helpdesk.example.com'),

    // API Key de tu empresa
    'api_key' => env('HELPDESK_API_KEY', ''),

    // Dimensiones del iframe
    'iframe_height' => env('HELPDESK_WIDGET_HEIGHT', '600px'),
    'iframe_width' => env('HELPDESK_WIDGET_WIDTH', '100%'),
    'iframe_border' => env('HELPDESK_WIDGET_BORDER', false),

    // Cache de tokens (en minutos)
    'token_cache_ttl' => env('HELPDESK_TOKEN_CACHE_TTL', 55),

    // Debug mode
    'debug' => env('HELPDESK_DEBUG', false),
];

// Intentos en orden:
$user->first_name
$user->name        // Separa por espacios
$user->profile->first_name  // Si existe relación

// app/View/Components/CustomHelpdeskWidget.php
namespace App\View\Components;

use Lukehowland\HelpdeskWidget\View\Components\HelpdeskWidget;

class CustomHelpdeskWidget extends HelpdeskWidget
{
    protected function getUserFirstName($user): string
    {
        return $user->primer_nombre; // Tu atributo personalizado
    }
    
    protected function getUserLastName($user): string
    {
        return $user->apellido;
    }
}
bash
php artisan helpdeskwidget:install
bash
php artisan config:clear
bash
# Instalación básica
php artisan helpdeskwidget:install

# Sobrescribir archivos existentes
php artisan helpdeskwidget:install --force

# No agregar ruta automáticamente
php artisan helpdeskwidget:install --skip-route

# No mostrar instrucciones de AdminLTE
php artisan helpdeskwidget:install --skip-adminlte
blade
{{-- Uso básico --}}
<x-helpdesk-widget />

{{-- Con parámetros personalizados --}}
<x-helpdesk-widget 
    height="800px" 
    width="100%" 
    :border="true" 
/>
bash
php artisan vendor:publish --tag=helpdeskwidget-config
bash
php artisan config:clear