<?php

namespace App\Controllers\Api;

use App\Models\ServiceZoneModel;

class GeoController extends BaseApiController
{
    /**
     * GET api/geo/check?latitude=0&longitude=0 - check if point is in service zone.
     */
    public function check()
    {
        $lat = (float) ($this->request->getGet('latitude') ?? 0);
        $lng = (float) ($this->request->getGet('longitude') ?? 0);
        $model = model(ServiceZoneModel::class);
        $inZone = $model->isInServiceZone($lat, $lng);
        return $this->success([
            'in_service_zone' => $inZone,
        ]);
    }
}
