1. Go to this page and download the library: Download madad/laravel-sdk 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/ */
public function madadPrice(): float { return $this->cents / 100; }
// Image URLs must be publicly reachable — Madad fetches and stores its own copy.
public function madadImages(): array
{
return [
['url' => config('services.madad.placeholder_image'), 'sort_order' => 0],
];
}
public function madadImages(): array
{
$real = $this->photos->pluck('url')->filter()->values(); // your own relation
if ($real->isNotEmpty()) {
return $real->map(fn ($url, $i) => ['url' => $url, 'sort_order' => $i])->all();
}
return [['url' => config('services.madad.placeholder_image'), 'sort_order' => 0]];
}
use Madad\Sdk\Concerns\SyncsWithMadad;
class Product extends Model
{
use SyncsWithMadad;
}
public function shouldSyncToMadad(): bool
{
// Only sync products under your "Building Materials" branch.
return $this->category && $this->category->isDescendantOf($buildingMaterialsId);
}
use Madad\Sdk\Facades\Madad;
Madad::ping(); // returns your account + inherited defaults
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.