55 lines
1.6 KiB
PHP
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');
|
|
}
|
|
}
|