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:
1 parent
6b03c0fbc3
commit
99f786265e
13 files changed
+1106
-2
No files matched your search
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\Admin;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class UpdateTestimonialRequest extends FormRequest
|
||||
{
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'image' => 'nullable|string|max:255',
|
||||
'client_link' => 'nullable|string|max:255',
|
||||
'translations' => 'nullable|array',
|
||||
'translations.client_name' => 'nullable|array',
|
||||
'translations.client_name.fa' => 'nullable|string|max:255',
|
||||
'translations.client_name.en' => 'nullable|string|max:255',
|
||||
'translations.client_position' => 'nullable|array',
|
||||
'translations.client_position.fa' => 'nullable|string|max:255',
|
||||
'translations.client_position.en' => 'nullable|string|max:255',
|
||||
'translations.feedback' => 'nullable|array',
|
||||
'translations.feedback.fa' => 'nullable|string',
|
||||
'translations.feedback.en' => 'nullable|string',
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user