schneespur/app/Http/Controllers/Admin/WeatherRetryController.php
Michael 2c63440ed8 Revert: move code back to project root from schneespur/ subdirectory
- Reverts the schneespur/ subdirectory restructure (b8e426b)
- Restores package.json and vite.config.js (needed for npm build, were
  removed in an earlier cleanup before the restructure)
- Updates public/build/ assets with current Vite output (new content hashes)
2026-05-17 18:24:26 +00:00

40 lines
1.2 KiB
PHP

<?php
namespace App\Http\Controllers\Admin;
use App\Enums\WeatherMoment;
use App\Http\Controllers\Controller;
use App\Jobs\FetchWeather;
use App\Models\Job;
use Illuminate\Http\RedirectResponse;
class WeatherRetryController extends Controller
{
public function __invoke(Job $serviceJob, string $moment): RedirectResponse
{
$weatherMoment = WeatherMoment::from($moment);
$object = $serviceJob->customerObject;
$lat = null;
$lon = null;
if ($object !== null && $object->lat !== null && $object->lon !== null) {
$lat = (float) $object->lat;
$lon = (float) $object->lon;
} else {
$gpsPoint = $serviceJob->gpsPoints()->latest('timestamp')->first();
if ($gpsPoint !== null && $gpsPoint->lat !== null && $gpsPoint->lon !== null) {
$lat = (float) $gpsPoint->lat;
$lon = (float) $gpsPoint->lon;
}
}
if ($lat === null || $lon === null) {
return redirect()->back()->with('error', __('weather.retry_no_coordinates'));
}
FetchWeather::dispatch($serviceJob->id, $weatherMoment, $lat, $lon);
return redirect()->back()->with('success', __('weather.retry_dispatched'));
}
}