<?php

namespace App\Models;

use CodeIgniter\Model;

class TransportMapSettingsModel extends Model
{
    protected $table         = 'transport_map_settings';
    protected $primaryKey    = 'id';
    protected $returnType    = 'array';
    protected $useTimestamps = true;
    protected $updatedField  = 'updated_at';
    protected $createdField  = '';

    protected $allowedFields = [
        'default_provider', 'google_api_key', 'default_latitude',
        'default_longitude', 'default_zoom', 'updated_by',
    ];

    public function getSettings(): array
    {
        $row = $this->find(1);
        if (! $row) {
            return [
                'id'                => 1,
                'default_provider'  => 'openstreetmap',
                'google_api_key'    => null,
                'default_latitude'  => 26.0667000,
                'default_longitude' => 50.5577000,
                'default_zoom'      => 12,
            ];
        }

        return $row;
    }
}
