json([ 'data' => $this->service->getByPage($page), ]); } public function store(UpdateSectionPageRequest $request, StaticPage $page): JsonResponse { $section = $this->service->create($page, $request->validated()); return response()->json($section); } public function show(SectionPage $section): JsonResponse { return response()->json([ 'data' => $section, ]); } public function update(UpdateSectionPageRequest $request, SectionPage $sectionPage): JsonResponse { $validated = $request->validated(); // Merge files in data if ($request->hasFile('data')) { $validated['data'] = array_replace_recursive( $validated['data'] ?? [], $request->file('data') ); } $this->service->update($sectionPage, $validated); session()->flash('success', 'Section mise à jour avec succès.'); return response()->json([ 'message' => 'Section mise à jour', 'data' => $sectionPage, ]); } public function destroy(SectionPage $section): JsonResponse { $this->service->delete($section); return response()->json([ 'message' => 'Section supprimée', 'data' => $section, ]); } public function toggleVisibility(SectionPage $section): JsonResponse { $section = $this->service->toggleVisibility($section); return response()->json([ 'data' => $section, ]); } }