Aller au contenu
← Retour aux projets

Laravel Tawk To

Laravel Tawk.to

#Laravel Tawk.to

Latest Version on Packagist GitHub Code Style Action Status Total Downloads

Add Tawk.to — free live chat widget for customer support — to your Laravel app. The settings are stored in the database with spatie/laravel-settings, so you can change them at runtime (e.g. from an admin panel) instead of in .env.

For a Filament settings page, use jeffersongoncalves/filament-tawk-to.

#Installation

composer require jeffersongoncalves/laravel-tawk-to

Publish and run the settings migration:

php artisan vendor:publish --tag=tawk-to-settings-migrations
php artisan migrate

#Configuration

$settings = tawk_to_settings();
$settings->property_id = '0123456789abcdef01234567';
$settings->widget_id = 'default';
$settings->save();

Or through the settings class or the Facade:

use JeffersonGoncalves\TawkTo\Facades\TawkTo;
use JeffersonGoncalves\TawkTo\Settings\TawkToSettings;

$settings = app(TawkToSettings::class);
$value = TawkTo::getFacadeRoot()->property_id;

#Available settings

Setting Type Default Description
property_id ?string null Your Tawk.to property id. The script only renders when it is valid.
widget_id string 'default' Widget ID from the embed code.
identify_users bool false Send the signed-in user's name and email to the chat.
only_when_open bool false Hide the chat while laravel-open-hours says you're closed (ignored when it isn't installed).

#Identify users and opening hours

  • identify_users: sends the signed-in user's name and email to Tawk.to, so your agents see who they're talking to. Leave it off on pages served from a shared full-page cache.
  • only_when_open: with jeffersongoncalves/laravel-open-hours installed, the widget is only rendered while you're open.
composer require jeffersongoncalves/laravel-open-hours

#Usage

Add the script to your Blade layout, right before </body>:

@include('tawk-to::script')

Nothing is rendered until the settings are complete, so you can ship the include everywhere and turn Tawk.to on later.

#Testing

composer test

#Changelog

Please see CHANGELOG for more information on what has changed recently.

#Contributing

Please see CONTRIBUTING for details.

#Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.

#Credits

#License

The MIT License (MIT). Please see License File for more information.

Nouvelle version disponible.