Add neutral diagnostic framework for future reporting modules: - DiagnosticReporterInterface, Registry, Manager, PayloadSanitizer - Laravel exception hook in bootstrap/app.php - Module permission declarations (requires_permissions in module.json) - Core diagnostic report points (module boot/install/update failures) - Module documentation update (moduldoku.md) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
45 lines
1.4 KiB
PHP
45 lines
1.4 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers\Driver;
|
|
|
|
use App\Http\Controllers\Controller;
|
|
use App\Services\JobLifecycleService;
|
|
use App\Services\PhotoService;
|
|
use Illuminate\Http\JsonResponse;
|
|
use Illuminate\Http\Request;
|
|
use Illuminate\Support\Facades\Storage;
|
|
|
|
class DriverPhotoController extends Controller
|
|
{
|
|
public function store(Request $request): JsonResponse
|
|
{
|
|
$validated = $request->validate([
|
|
'photo' => ['required', 'image', 'mimes:jpeg,png,heic,webp', 'max:10240'],
|
|
'caption' => ['nullable', 'string', 'max:255'],
|
|
]);
|
|
|
|
$job = app(JobLifecycleService::class)->findActiveJob($request->user());
|
|
|
|
if (! $job) {
|
|
return response()->json(['message' => __('job.no_active_job')], 422);
|
|
}
|
|
|
|
if (! PhotoService::canAddPhoto($job)) {
|
|
return response()->json([
|
|
'message' => __('job.photo_limit_reached', ['max' => PhotoService::MAX_PHOTOS_PER_JOB]),
|
|
], 422);
|
|
}
|
|
|
|
$photo = app(PhotoService::class)->store($validated['photo'], $job);
|
|
|
|
if (! empty($validated['caption'])) {
|
|
$photo->update(['caption' => $validated['caption']]);
|
|
}
|
|
|
|
return response()->json([
|
|
'id' => $photo->id,
|
|
'thumbnail_url' => Storage::disk('public')->url($photo->thumbnail_path),
|
|
'photos_remaining' => PhotoService::MAX_PHOTOS_PER_JOB - $job->jobPhotos()->count(),
|
|
], 201);
|
|
}
|
|
}
|