gps_system/app/Livewire/MapSettings.php
sackey 6b878bb0a0
Some checks failed
linter / quality (push) Has been cancelled
tests / ci (push) Has been cancelled
Initial commit
2025-09-12 16:19:56 +00:00

55 lines
1.6 KiB
PHP

<?php
namespace App\Livewire;
use Livewire\Component;
use App\Services\MapService;
use Illuminate\Support\Facades\Config;
class MapSettings extends Component
{
public $googleMapsApiKey = '';
public $mapboxApiKey = '';
public $defaultProvider = 'openstreetmap';
public $providersStatus = [];
public function mount()
{
$this->googleMapsApiKey = config('services.maps.providers.google.api_key', '');
$this->mapboxApiKey = config('services.maps.providers.mapbox.api_key', '');
$this->defaultProvider = config('services.maps.default_provider', 'openstreetmap');
$this->loadProvidersStatus();
}
public function loadProvidersStatus()
{
$mapService = app(MapService::class);
$this->providersStatus = $mapService->getAllProvidersStatus();
}
public function saveSettings()
{
// Note: In a real application, you would save these to a database
// or update the .env file programmatically
session()->flash('success', 'Settings saved! Please update your .env file with the API keys and restart the application.');
}
public function testProvider($provider)
{
$mapService = app(MapService::class);
if ($mapService->isProviderEnabled($provider)) {
session()->flash('success', "{$provider} is configured and working!");
} else {
session()->flash('error', "{$provider} requires API key configuration.");
}
$this->loadProvidersStatus();
}
public function render()
{
return view('livewire.map-settings');
}
}