schneespur/app/Http/Controllers/Api/OwnTracksController.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

49 lines
1.4 KiB
PHP

<?php
namespace App\Http\Controllers\Api;
use App\Http\Controllers\Controller;
use App\Models\GpsPoint;
use App\Services\JobLifecycleService;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
class OwnTracksController extends Controller
{
public function store(Request $request): JsonResponse
{
if ($request->input('_type') !== 'location') {
return response()->json([], 200);
}
$validated = $request->validate([
'lat' => 'required|numeric',
'lon' => 'required|numeric',
'tst' => 'required|integer',
'alt' => 'nullable|numeric',
'batt' => 'nullable|integer',
'vel' => 'nullable|integer',
'acc' => 'nullable|integer',
]);
$activeJob = app(JobLifecycleService::class)->findActiveJob($request->user());
if ($activeJob === null) {
return response()->json([], 200);
}
GpsPoint::create([
'user_id' => $request->user()->id,
'job_id' => $activeJob->id,
'lat' => $validated['lat'],
'lon' => $validated['lon'],
'timestamp' => $validated['tst'],
'altitude' => $validated['alt'] ?? null,
'battery' => $validated['batt'] ?? null,
'velocity' => $validated['vel'] ?? null,
'accuracy' => $validated['acc'] ?? null,
]);
return response()->json([], 200);
}
}