- MacroImportController + LabelImportController: POST endpoints accepting uploaded .bin files,
delegating to MacrosImportService / LabelsImportService and returning import stats / warnings as JSON.
Generic German 422 error if parser rejects the file.
- MacroAssignmentController: index renders Settings Inertia page with assignments / macros / labels /
collections / last-import metadata. store/update/destroy/reorder for global MacroAssignment rows.
- ServiceMacroOverrideController: store snapshots all matching global MacroAssignments into
service-specific rows when a service opts to override; destroy removes both override and
service-specific assignments. storeAssignment / updateAssignment / destroyAssignment manage the
per-service rows directly.
- routes/web.php: 12 new named routes inside the auth middleware group; reorder route placed before
{macroAssignment} parameter route to avoid capture conflict.
- Tests: 19 new Pest tests across 4 feature files (54 assertions). Full suite 376 passed.
38 lines
1 KiB
PHP
38 lines
1 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
use App\Services\LabelsImportService;
|
|
use Illuminate\Http\JsonResponse;
|
|
use Illuminate\Http\Request;
|
|
use Throwable;
|
|
|
|
class LabelImportController extends Controller
|
|
{
|
|
public function __construct(
|
|
private readonly LabelsImportService $importService,
|
|
) {}
|
|
|
|
public function store(Request $request): JsonResponse
|
|
{
|
|
$request->validate(['file' => ['required', 'file', 'max:5120']]);
|
|
|
|
$file = $request->file('file');
|
|
$tempPath = $file->getPathname();
|
|
|
|
try {
|
|
$result = $this->importService->import($tempPath, $file->getClientOriginalName());
|
|
} catch (Throwable $e) {
|
|
return response()->json([
|
|
'message' => 'Die Datei konnte nicht gelesen werden. Stelle sicher, dass es eine gültige ProPresenter Labels-Datei ist.',
|
|
], 422);
|
|
}
|
|
|
|
return response()->json([
|
|
'new' => $result->newCount,
|
|
'updated' => $result->updatedCount,
|
|
'total' => $result->totalInFile,
|
|
]);
|
|
}
|
|
}
|