Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Addchat Laravel Laravel Package

htuzel/addchat-laravel

View on GitHub
Deep Wiki
Context7

Getting Started

Minimal Setup

  1. Installation

    composer require htuzel/addchat-laravel
    

    Publish the config file:

    php artisan vendor:publish --provider="Htuzel\Addchat\AddchatServiceProvider" --tag="config"
    
  2. Configuration Edit config/addchat.php and set your Turacoon API credentials:

    'api_key' => env('ADDCONFIG_API_KEY'),
    'widget_id' => env('ADDCONFIG_WIDGET_ID'),
    
  3. First Use Case Add the widget to your Blade template:

    @addchat
    

    Or programmatically in a controller:

    use Htuzel\Addchat\Facades\Addchat;
    
    Addchat::render();
    

Implementation Patterns

Common Workflows

  1. Dynamic Widget Rendering Conditionally render the widget based on user roles or other logic:

    if (auth()->check() && auth()->user()->isPremium()) {
        Addchat::render();
    }
    
  2. Customizing Widget Behavior Use the facade to pass custom settings:

    Addchat::render([
        'theme' => 'dark',
        'position' => 'bottom-right'
    ]);
    
  3. Integration with Events Listen to chat events (e.g., new messages) via Turacoon’s webhooks and update your Laravel app accordingly:

    Route::post('/turacoon-webhook', function (Request $request) {
        // Process webhook data
    });
    
  4. Localization Override default widget labels by extending the package’s language files in resources/lang.

Best Practices

  • Environment Variables: Always store ADDCONFIG_API_KEY and ADDCONFIG_WIDGET_ID in .env.
  • Caching: If using Turacoon’s API for dynamic data, cache responses to reduce API calls:
    $data = Cache::remember('turacoon_chat_data', now()->addHours(1), function () {
        return Http::get('https://api.turacoon.com/...')->json();
    });
    

Gotchas and Tips

Pitfalls

  1. Missing Config Forgetting to publish the config file will result in Undefined config errors. Always run:

    php artisan vendor:publish --tag="config"
    
  2. CORS Issues If Turacoon’s API or webhooks fail silently, check your Laravel CORS settings in config/cors.php to ensure Turacoon’s domain is whitelisted.

  3. Widget Not Loading

    • Verify the widget_id in the config matches Turacoon’s dashboard.
    • Ensure JavaScript is not blocked by ad blockers or browser extensions.
  4. Rate Limiting Turacoon’s API may throttle requests. Implement exponential backoff in your webhook handlers:

    use Symfony\Component\HttpClient\Retry\RetryStrategy;
    
    $client = Http::withOptions([
        'retry' => RetryStrategy::fromCalls(3, 100)
    ]);
    

Debugging Tips

  • Log Webhook Payloads Add a middleware to log incoming Turacoon webhook data for debugging:

    public function handle(Request $request, Closure $next) {
        if ($request->is('turacoon-webhook')) {
            \Log::info('Turacoon Webhook', $request->all());
        }
        return $next($request);
    }
    
  • Check JavaScript Console If the widget fails to load, inspect the browser console for errors like missing API keys or invalid widget IDs.

Extension Points

  1. Custom Events Extend the package by listening to Turacoon’s webhooks and triggering Laravel events:

    event(new ChatMessageReceived($webhookData));
    
  2. Override Views Publish and modify the widget’s Blade views:

    php artisan vendor:publish --tag="views"
    
  3. API Wrapper Create a service class to wrap Turacoon’s API calls for better maintainability:

    class TuracoonService {
        public function getChatStatus() {
            return Http::get('https://api.turacoon.com/...')->json();
        }
    }
    
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
jayeshmepani/jpl-moshier-ephemeris-php
elnasnato/laraliveui
labrodev/rest-sdk
sampaui/sampaui
babelqueue/php-sdk
facebook/capi-param-builder-php
babelqueue/symfony
hamzi/corewatch
minionfactory/raw-hydrator
hexters/coinpayment
rjcodes/rjcms
act-training/laravel-permissions-manager
alimarchal/laravel-chart-of-accounts
babenkoivan/elastic-scout-driver
mkwebdesign/filament-watchdog-v5
renatomarinho/laravel-page-speed
zedmagdy/filament-business-hours
renatovdemoura/blade-elements-ui
devgeek/beacon-admin
benjamin-rqt/data-watcher-bundle