PHP code example of cldt / laravel-aircall

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

    

cldt / laravel-aircall example snippets



use CLDT\Aircall\Facades\Aircall;

// Get all calls
$allCalls = Aircall::calls()->all();

// Get a teams by id
$call = Aircall::teams()->find($id);

// Get all users 
$allContacts = Aircall::users([
    "from" => "1729028410",
])->all();


namespace App\Jobs\AircallWebhooks;

use Illuminate\Bus\Queueable;
use Illuminate\Queue\SerializesModels;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Contracts\Queue\ShouldQueue;
use CLDT\Aircall\Models\AircallWebhookCall;

class HandleUserCreatedWebhookJob implements ShouldQueue
{
    use InteractsWithQueue, Queueable, SerializesModels;

    public AircallWebhookCall $aircallWebhookCall;

    public function __construct(
        public AircallWebhookCall $webhookCall
    ) {}

    public function handle()
    {
        // do your work here

        // you can access the payload of the webhook call with `$this->webhookCall->payload`
    }
}

// config/aircall.php

'webhook_jobs' => [
   'user.created' => \App\Jobs\Aircall\HandleAircallUserCreatedJob::class, // will be called when user are created
   '*' => \App\Jobs\Aircall\HandleAllWebhooks::class // will be called when any event/action comes in
],

/**
 * The event listener mappings for the application.
 *
 * @var array
 */
protected $listen = [
    'aircall::user.created' => [
        App\Listeners\UserCreated::class,
    ],
];



namespace App\Listeners;

use Illuminate\Contracts\Queue\ShouldQueue;
use CLDT\Aircall\Models\AircallWebhookCall;

class UserCreated implements ShouldQueue
{
    public function handle(AircallWebhookCall $webhookCall)
    {
        // do your work here

        // you can access the payload of the webhook call with `$webhookCall->payload`
    }
}

$schedule->command('model:prune', [
    '--model' => [\CLDT\Aircall\Models\AircallWebhookCall::class],
])->daily();
bash
php artisan vendor:publish --provider="CLDT\Aircall\AircallServiceProvider" --tag="aircall-config"
bash
php artisan vendor:publish --provider="CLDT\Aircall\AircallServiceProvider" --tag="aircall-migrations"
bash
php artisan migrate