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.
28 lines
831 B
PHP
28 lines
831 B
PHP
<?php
|
|
|
|
namespace App\Http\Controllers\Api\Website;
|
|
|
|
use App\Http\Controllers\Controller;
|
|
use App\Models\Website\ProjectCategory;
|
|
use Illuminate\Http\Request;
|
|
|
|
class ProjectCategoryController extends Controller
|
|
{
|
|
public function index(Request $request)
|
|
{
|
|
$locale = $request->query('locale', 'fa');
|
|
|
|
$categories = ProjectCategory::query()->get();
|
|
|
|
return response()->json([
|
|
'data' => $categories->map(function (ProjectCategory $category) use ($locale) {
|
|
return [
|
|
'id' => $category->id,
|
|
'title' => $category->getTranslation('title', $locale),
|
|
'description' => $category->getTranslation('description', $locale),
|
|
'image' => $category->image,
|
|
];
|
|
}),
|
|
]);
|
|
}
|
|
} |