Laravel Backpack Create/Update action that customize the foreign field

Viewed 130

I want the "Unit" field that saved to my model is not the default field (id), but instead customized field (e.g.: I want to save the Unit field with name from the foreign table, not the id)

enter image description here

How to do that? currently why CrudController is like this

enter image description here

1 Answers

If there’s a 1-to-1 relationship (hasOne) defined in your model, you should be able to do that by giving the field the name “unit.name”.

Related