Let the admin panel manage services, skills and testimonials

These three had read endpoints or nothing at all, so their content could only
be changed by hand in the database. All writes are admin-only and rate
limited like the existing admin routes.

Testimonials are the awkward one: the migration that collapsed the legacy
per-locale tables into JSON columns deliberately skipped them, so they still
live in a child table. Testimonial therefore exposes a translations accessor
to present the same translations[key][locale] shape as Service and Skill,
which is what the generic resource form binds to. Reading the child relation
has to go through getRelation(), since a plain $this->translations inside an
accessor of that name re-enters the accessor and silently yields nulls.

The store requests now mark the NOT NULL columns as required. Leaving them
nullable let a bad payload reach the database and come back as a 500 instead
of a 422, and about_me_id is additionally a cascading foreign key.

Also registers the three resources with the admin read endpoint so the panel
can list them, eager loading the relations their forms need.
This commit is contained in:
Parsa Aghayi committed 2026-10-01 18:19:32 -04:00
1 parent 6b03c0fbc3
commit 99f786265e
13 files changed
+1106 -2

No files matched your search

@@ -0,0 +1,34 @@
<?php
namespace App\Http\Requests\Admin;
use Illuminate\Foundation\Http\FormRequest;
class StoreSkillRequest extends FormRequest
{
public function authorize(): bool
{
return true;
}
public function rules(): array
{
return [
// image, percentage and about_me_id are all NOT NULL on
// website_skills, so they are required here to keep a bad payload a
// 422 instead of a 500. about_me_id is also a foreign key with
// ON DELETE CASCADE, hence exists:.
'image' => 'required|string|max:255',
'link' => 'nullable|string|max:255',
'percentage' => 'required|integer|min:0|max:100',
'about_me_id' => 'required|exists:website_about_me,id',
'translations' => 'required|array',
'translations.title' => 'required|array',
'translations.title.fa' => 'required|string|max:255',
'translations.title.en' => 'nullable|string|max:255',
'translations.description' => 'required|array',
'translations.description.fa' => 'required|string',
'translations.description.en' => 'nullable|string',
];
}
}