PHP code example of imazed / laravel-helpscout-beacon

1. Go to this page and download the library: Download imazed/laravel-helpscout-beacon 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/ */

    

imazed / laravel-helpscout-beacon example snippets


use Illuminate\Contracts\Auth\Authenticatable;
use Imazed\HelpScoutBeacon\Contracts\BuildsBeaconIdentity;
use Imazed\HelpScoutBeacon\Identity\BeaconIdentity;

class CustomerBeaconIdentity implements BuildsBeaconIdentity
{
    public function build(?Authenticatable $user): ?BeaconIdentity
    {
        if ($user === null) {
            return null;
        }

        return BeaconIdentity::for($user->email)
            ->name($user->name)
            ->company($user->team->name)
            ->avatar($user->avatar_url)
            ->attribute('plan', $user->plan)
            ->attribute('customer-since', $user->created_at)
            ->companyProperty('industry', $user->team->industry);
    }
}

use Imazed\HelpScoutBeacon\Facades\HelpScoutBeacon;

HelpScoutBeacon::sessionData([
    'order' => $order->number,
    'cart-total' => $cart->total,
]);

HelpScoutBeacon::suppress();   // no Beacon on this page (this request only)
HelpScoutBeacon::logout();     // for logouts that skip Laravel's Logout event
bash
php artisan vendor:publish --tag=helpscout-beacon-config