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.
24 lines
453 B
PHP
24 lines
453 B
PHP
<?php
|
|
|
|
namespace App\Models\Website;
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
class TestimonialTranslation extends Model
|
|
{
|
|
protected $table = 'website_testimonial_translations';
|
|
|
|
protected $fillable = [
|
|
'testimonial_id',
|
|
'locale',
|
|
'client_name',
|
|
'client_position',
|
|
'feedback',
|
|
];
|
|
|
|
public function testimonial()
|
|
{
|
|
return $this->belongsTo(Testimonial::class, 'testimonial_id');
|
|
}
|
|
}
|