1. Go to this page and download the library: Download malikad778/laravel-nexus 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/ */
malikad778 / laravel-nexus example snippets
// Identical API regardless of channel
Nexus::driver('shopify')->fetchProduct($remoteId);
Nexus::driver('amazon')->updateInventory($remoteId, 42);
Nexus::driver('woocommerce')->getProducts(now()->subHours(24));
// Push a single inventory update to specific channels
Nexus::product($product)
->updateInventory(quantity: 42)
->sync(['shopify', 'amazon']);
// Bulk sync your entire catalog across all channels
$batch = Nexus::catalog($products)->syncAll();
// Monitor batch progress
$status = Nexus::batch($batchId)->status();
class PropagateInventoryToOtherChannels
{
public function handle(InventoryUpdated $event): void
{
$others = ['shopify', 'amazon', 'woocommerce', 'etsy'];
Nexus::product($event->product)
->updateInventory($event->newQuantity)
->sync(array_diff($others, [$event->channel]));
}
}
use Malikad778\\LaravelNexus\Traits\Syncable;
class Product extends Model
{
use Syncable;
// Adds: $product->channelMappings(), $product->syncTo('shopify')
}
// In AppServiceProvider::boot()
Nexus::extend('ebay', function ($app) {
return new EbayInventoryDriver(
config: $app['config']['nexus.channels.ebay'],
client: $app->make(EbayApiClient::class)
);
});
// eBay is now a first-class channel
Nexus::product($product)->updateInventory(10)->sync(['shopify', 'ebay']);
use Malikad778\\LaravelNexus\Facades\Nexus;
// All configured channels
Nexus::product($product)->updateInventory(quantity: 42)->sync();
// Specific channels only
Nexus::product($product)->updateInventory(quantity: 42)->sync(['shopify', 'amazon']);
use Malikad778\\LaravelNexus\Traits\Syncable;
class Product extends Model
{
use Syncable;
}
// Access channel mappings
$shopifyId = $product->channelMappings()->where('channel', 'shopify')->value('remote_id');