PHP code example of cboxdk / laravel-sync-client

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

    

cboxdk / laravel-sync-client example snippets


use Cbox\Sync\Client\Laravel\SyncClient;
use Cbox\Sync\Data\FieldOperation;
use Cbox\Sync\Enums\MutationKind;

$client = app(SyncClient::class);

// Works with no network. The write is queued locally and durably.
$entity = $client->key('tasks', $teamId, $taskId);
$client->outbox()->queue($entity, MutationKind::Update, [
    FieldOperation::set('title', $title),
], $baseVersion);

// When there is a connection.
$outcome = $client->sync('tasks', $teamId);

$client->record('tasks', $teamId, $taskId);