1. Go to this page and download the library: Download jeffgreco13/laravel-wave 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/ */
jeffgreco13 / laravel-wave example snippets
return [
'access_token' => env('WAVE_ACCESS_TOKEN'),
'graphql_uri' => env('WAVE_GRAPHQL_URI', 'https://gql.waveapps.com/graphql/public'),
'business_id' => env('WAVE_BUSINESS_ID'),
// Override with your own Eloquent models (see "Custom Models" below)
'models' => [
'customer' => \Jeffgreco13\Wave\Models\WaveCustomer::class,
'invoice' => \Jeffgreco13\Wave\Models\WaveInvoice::class,
'product' => \Jeffgreco13\Wave\Models\WaveProduct::class,
'sales_tax' => \Jeffgreco13\Wave\Models\WaveSalesTax::class,
'vendor' => \Jeffgreco13\Wave\Models\WaveVendor::class,
'business' => \Jeffgreco13\Wave\Models\WaveBusiness::class,
'account' => \Jeffgreco13\Wave\Models\WaveAccount::class,
],
'sync' => [
'chunk_size' => 150, // records per page during sync
],
];
use Jeffgreco13\Wave\WaveService;
class InvoiceController extends Controller
{
public function __construct(protected WaveService $wave) {}
public function index()
{
// Returns a Collection of Node objects
return $this->wave->getCustomers(['page' => 1, 'pageSize' => 20]);
}
}
use Jeffgreco13\Wave\Jobs\SyncCustomersFromWave;
// Queue
SyncCustomersFromWave::dispatch();
// Or via Artisan
php artisan wave:sync-customers
// Sync records modified in the last 24 hours
SyncCustomersFromWave::dispatch(since: now()->subDay());
use Jeffgreco13\Wave\Models\WaveCustomer;
use Jeffgreco13\Wave\Models\WaveInvoice;
// Active customers
WaveCustomer::active()->get();
// Find by Wave ID
WaveCustomer::where('wave_id', $id)->first();
// Unpaid invoices for a customer
WaveInvoice::active()->forCustomer($waveCustomerId)->status('UNPAID')->get();
use Jeffgreco13\Wave\Jobs\CreateWaveCustomer;
use Jeffgreco13\Wave\Jobs\UpdateWaveCustomer;
use Jeffgreco13\Wave\Jobs\DeleteWaveCustomer;
// Create in Wave and upsert locally
CreateWaveCustomer::dispatch([
'name' => 'Acme Corp',
'email' => '[email protected]',
]);
// Update (must
// app/Models/Customer.php
use Jeffgreco13\Wave\Traits\HasWaveSync;
class Customer extends Model
{
use HasWaveSync;
protected $fillable = ['wave_id', 'company_name', 'email', 'currency_code'];
/**
* Map local column names to Wave API field paths.
* Use dot-notation for nested Wave objects.
*/
public function waveAttributeMap(): array
{
return [
'wave_id' => 'id',
'company_name' => 'name',
'email' => 'email',
'currency_code' => 'currency.code',
];
}
}
use Jeffgreco13\Wave\Data\CustomerSort;
use Jeffgreco13\Wave\Data\InvoiceSort;
use Jeffgreco13\Wave\Data\InvoiceStatus;
use Jeffgreco13\Wave\Data\InvoiceCreateStatus;
use Jeffgreco13\Wave\Data\ProductSort;
$wave->getCustomers(['sort' => CustomerSort::NAME_ASC]);
$wave->getInvoices(['status' => InvoiceStatus::UNPAID]);