I am facing issue for storing data in two table from one resouce file, below is my code structure.
I have two tables One is Plan table and other is Plan_translation table,
Plan table contains the following fields.
plan Table
plan_id,status,is_active
Plan Translation table contains the following fields.
Plan_translation table,
id, plan_id, language_id, Plan_name
plan translation table contain plan name in 2 different langauage.
I have following relationship in plan model.
public function translations()
{
return $this->hasMany(
\App\PlanTranslation::class,
'plan_id', 'id'
);
}
below is my resource file for plan table.
class PaymentStatus extends Resource
{
public static $model = 'App\Plan';
public static $title = 'name';
public static $with = [ 'translation', ];
public function fields(Request $request)
{
return [
ID::make()->sortable(),
HasMany::make('PlanTranslation', 'translations'),
];
}
}
can someone help me how can I update plan name from this resource ?