23 lines
734 B
PHP
23 lines
734 B
PHP
<?php
|
|
|
|
namespace App\Services;
|
|
|
|
use App\Models\Supplier;
|
|
use Illuminate\Database\Eloquent\Builder;
|
|
|
|
class SupplierGeography
|
|
{
|
|
/** Current supplier registration only; never infer geography from address text or evaluation snapshots.
|
|
* @return Builder<Supplier>
|
|
*/
|
|
public function matching(string $location): Builder
|
|
{
|
|
$geography = app(AdministrativeGeography::class);
|
|
abort_unless($geography->enabled(), 503);
|
|
|
|
return Supplier::query()->where('geography_reference->country', 'MZ')
|
|
->where('geography_reference->catalogue', $geography->catalogue()['manifest']['source_sha256'])
|
|
->whereIn('geography_reference->record_id', $geography->descendants($location));
|
|
}
|
|
}
|