PHP code example of twisted-binary / laravel-feedback-widget

1. Go to this page and download the library: Download twisted-binary/laravel-feedback-widget 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/ */

    

twisted-binary / laravel-feedback-widget example snippets


return [
    'route_prefix' => env('FEEDBACK_WIDGET_ROUTE_PREFIX', 'feedback'),
    'middleware' => ['web', 'auth', 'verified'],
    'throttle' => [
        'chat' => '30,1',   // 30 requests per minute
        'issue' => '5,1',   // 5 requests per minute
    ],
    'openai_model' => env('OPENAI_FEEDBACK_MODEL', 'gpt-4o-mini'),
    'github' => [
        'app_id' => env('GITHUB_APP_ID'),
        'private_key' => env('GITHUB_APP_PRIVATE_KEY'),
        'installation_id' => env('GITHUB_APP_INSTALLATION_ID'),
        'repo_owner' => env('GITHUB_REPO_OWNER'),
        'repo_name' => env('GITHUB_REPO_NAME'),
        'feedback_label' => env('GITHUB_FEEDBACK_LABEL', 'user-feedback'),
    ],
    'screenshot_disk' => 'public',
    'screenshot_path' => 'feedback-screenshots',
    'app_name' => env('FEEDBACK_WIDGET_APP_NAME', env('APP_NAME', 'the application')),
    'locale' => env('FEEDBACK_WIDGET_LOCALE', null), // null = app()->getLocale()
    'track_ai_costs' => env('FEEDBACK_WIDGET_TRACK_AI_COSTS', true),
];

use TwistedBinary\FeedbackWidget\Models\FeedbackAiCost;

// Total tokens for a conversation
FeedbackAiCost::forConversation($id)->sum('total_tokens');

// All costs for a user
FeedbackAiCost::forUser($userId)->get();

// Daily token usage
FeedbackAiCost::whereDate('created_at', today())->sum('total_tokens');

use TwistedBinary\FeedbackWidget\Events\FeedbackAiCostRecorded;

Event::listen(FeedbackAiCostRecorded::class, function (FeedbackAiCostRecorded $event) {
    // Report to an external service, log, etc.
});
bash
php artisan vendor:publish --tag=feedback-widget-config
bash
php artisan vendor:publish --tag=feedback-widget-migrations
php artisan migrate