first(); return response()->json($aboutMe); } public function show($id) { $aboutMe = AboutMe::with('skills')->findOrFail($id); return response()->json($aboutMe); } public function store(StoreAboutMeRequest $request) { $aboutMe = AboutMe::create($request->validated()); return response()->json($aboutMe, 201); } public function update(UpdateAboutMeRequest $request, $id) { $aboutMe = AboutMe::findOrFail($id); $aboutMe->update($request->validated()); return response()->json($aboutMe); } public function destroy($id) { AboutMe::destroy($id); return response()->json(null, 204); } public function getTranslation($id, $locale) { $aboutMe = AboutMe::with('skills')->findOrFail($id); if (!$aboutMe->hasTranslation('title', $locale)) { return response()->json(['message' => 'Translation not found', 'locale' => $locale], 404); } $skills = $aboutMe->skills->map(function ($skill) use ($locale) { return [ 'id' => $skill->id, 'title' => $skill->getTranslation('title', $locale), 'description' => $skill->getTranslation('description', $locale), 'image' => $skill->image, 'link' => $skill->link, 'percentage' => $skill->percentage, ]; }); $data = [ 'id' => $aboutMe->id, 'title' => $aboutMe->getTranslation('title', $locale), 'description' => $aboutMe->getTranslation('description', $locale), 'image' => $aboutMe->image, 'skills' => $skills, ]; return response()->json($data); } }