Expose About Me translations and project categories for the admin panel
Deploy Backend / deploy (push) Waiting to run
Deploy Backend / deploy (push) Waiting to run
About-me writes could only set the image: title and description live in the JSON translations column and were unreachable from the API, so the homepage bio could never be edited. Accept title_fa/title_en/description_fa/ description_en on both About Me form requests and write them through setTranslation() for each locale. Adds a read-only GET /api/website/project-categories endpoint backed by the existing (previously unreachable) ProjectCategory model, so project forms can offer a category picker.
This commit is contained in:
1 parent
d2f6bd4d7d
commit
7ee8440a65
5 files changed
+64
-4
No files matched your search
@@ -52,7 +52,9 @@ class AboutMeController extends Controller
|
||||
*/
|
||||
public function store(StoreAboutMeRequest $request)
|
||||
{
|
||||
$aboutMe = AboutMe::create($request->validated());
|
||||
$aboutMe = AboutMe::create(['image' => $request->input('image')]);
|
||||
$this->applyTranslations($aboutMe, $request);
|
||||
|
||||
return response()->json($aboutMe, 201);
|
||||
}
|
||||
|
||||
@@ -69,10 +71,29 @@ class AboutMeController extends Controller
|
||||
public function update(UpdateAboutMeRequest $request, $id)
|
||||
{
|
||||
$aboutMe = AboutMe::findOrFail($id);
|
||||
$aboutMe->update($request->validated());
|
||||
|
||||
if ($request->has('image')) {
|
||||
$aboutMe->image = $request->input('image');
|
||||
}
|
||||
|
||||
$this->applyTranslations($aboutMe, $request);
|
||||
$aboutMe->save();
|
||||
|
||||
return response()->json($aboutMe);
|
||||
}
|
||||
|
||||
private function applyTranslations(AboutMe $aboutMe, $request): void
|
||||
{
|
||||
foreach (['fa', 'en'] as $locale) {
|
||||
foreach (['title', 'description'] as $key) {
|
||||
$field = $key.'_'.$locale;
|
||||
if ($request->has($field)) {
|
||||
$aboutMe->setTranslation($key, $locale, $request->input($field));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @OA\Delete(
|
||||
* path="/website/about-me/{id}",
|
||||
|
||||
Reference in new issue
Block a user