PHP code example of beziworld / laravel-livespace
1. Go to this page and download the library: Download beziworld/laravel-livespace 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/ */
beziworld / laravel-livespace example snippets
use Beziworld\Livespace\Facades\Livespace;
$person = Livespace::persons()->create([
'firstname' => 'Jan',
'lastname' => 'Kowalski',
'emails' => ['[email protected] '],
'phones' => [['phone_no' => '600100200', 'type' => 2, 'is_default' => 1]], // 1 phone, 2 mobile, 3 fax
'company' => ['name' => 'Firma Sp. z o.o.', 'nip' => '111-222-55-00'],
'dataset' => ['87de5630-d889-bdb1-bd09-d61335d27ff8' => 'value'], // custom fields
], checkIfExists: true, wall: false);
$person = Livespace::persons()->get($person->id);
$person->email();
Livespace::persons()->findByEmail('[email protected] ');
Livespace::persons()->search(['tags' => ['vip'], 'modified' => ['from' => now()->subDay()]], limit: 100);
foreach (Livespace::persons()->lazy() as $person) { /* every person, page by page */ }
Livespace::persons()->update($person->id, ['position' => 'CEO']);
Livespace::persons()->tag($person->id, add: ['newsletter'], remove: ['lead']);
Livespace::persons()->assignCompany($person->id, 'Firma Sp. z o.o.'); // ID or name; null removes
Livespace::persons()->setConsents($person->id, [['id' => $consentId, 'status_id' => $statusId]]);
Livespace::persons()->addCall($person->id, '+48600100200', outbound: true, durationSeconds: 231);
Livespace::persons()->merge($person->id, [$duplicateId]);
$company = Livespace::companies()->findByNip('PL 111-222-55-00');
Livespace::companies()->create(['name' => 'Bank XYZ', 'client_status' => 'current_client']);
Livespace::companies()->setClientStatus($company->id, 'former_client');
$deal = Livespace::deals()->create([
'name' => 'Website redesign',
'process_id' => $processId,
'company' => ['id' => $company->id],
'contact' => ['id' => $person->id],
'price' => '12500.00', // sent as "12500,00" with the default separator
'date_end' => now()->addMonth(),
]);
Livespace::deals()->search(['status' => ['open'], 'owner_login' => '[email protected] ']);
Livespace::deals()->openForCompany($company->id);
Livespace::deals()->markStages($deal->id, [$stageId, $otherStageId => false]);
Livespace::deals()->markWon($deal->id);
$deal->price; // "12500.00"
Livespace::tasks()->create([
'title' => 'Call back',
'date' => now()->addDays(2)->setTime(10, 0),
'priority' => 1,
'objects' => [['type' => 'deal', 'id' => $deal->id]],
]);
Livespace::tasks()->list(completed: false, from: today(), to: today()->addWeek());
Livespace::tasks()->forObject('company', $company->id);
Livespace::tasks()->complete($taskId);
Livespace::deals()->addTask($deal->id, 'Send the offer', today()->addDay());
Livespace::notes()->add('Offer sent', 'deal', $deal->id, tags: ['offer']);
Livespace::notes()->list('deal', $deal->id, types: ['note', 'email']);
Livespace::files()->attachToDeal($deal->id, URL::temporarySignedRoute('offers.pdf', now()->addHour(), $offer), 'Offer');
Livespace::users()->me();
Livespace::users()->all();
Livespace::users()->invite(['[email protected] '], [['structure_id' => [$teamId], 'role_id' => [$roleId], 'is_main' => 1]]);
Livespace::users()->lock('[email protected] ');
$industry = Livespace::fields()->find('company', 'Industry');
Livespace::companies()->update($company->id, ['dataset' => [$industry->id => $industry->optionId('IT')]]);
Livespace::search()->query('contact', 'jan kowalski');
use Beziworld\Livespace\Data\FormSubmission;
// From validated request input (name or first_name/last_name, email, phone, company, nip, message, city, ...)
Livespace::forms()->submit($request->validated(), source: 'contact form');
// Or explicitly
Livespace::forms()->submit(new FormSubmission(
name: 'Jan Kowalski',
email: '[email protected] ',
companyName: 'Firma Sp. z o.o.',
message: 'Please send an offer',
tags: ['website'],
taskTitle: 'Contact the lead',
taskDate: today()->addDays(3),
));
Livespace::connection('second-company')->deals()->search(['status' => 'open']);
Livespace::using([
'subdomain' => $tenant->livespace_subdomain,
'api_key' => $tenant->livespace_key,
'api_secret' => $tenant->livespace_secret,
])->persons()->create([...]);
Livespace::call('Space/getAll', ['type' => 'space'], read: true);
Livespace::call('Deal/product_add', ['name' => 'Consulting', 'sku' => 'C-1', 'default_price' => 150]);
Livespace::response('Default/ping', ['param1' => 'value1']); // status, result, data, error
bash
php artisan livespace:check # default: OK (https://acme.livespace.io, API user Jan Kowalski).
php artisan livespace:check --all