custom field saving strategy #5850
-
|
i am trying to set up EAV for a model called the is there a way i can specify the saving strategy so that it looks like a regular nova field, but actually uses relation in the background? for example: $customFieldId = 3;
Text::make("Custom Field $customFieldId", "customFields.$customFieldId")
->saveUsing(function ($request, $model, $attribute) {
$id = Str::replaceFirst('customFields.', '', $attribute);
$model->customFields()->updateOrCreate([
'id' => $id,
], [
'value' => $request->input($attribute),
]);
}); |
Beta Was this translation helpful? Give feedback.
Answered by
treed-eaglemetal
Aug 31, 2023
Replies: 1 comment 1 reply
-
|
i know i can use JSON field in |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
It sounds like you're looking for
fillUsing.https://nova.laravel.com/docs/resources/fields.html#field-hydration
If you need something to happen after the model is saved, you can return a closure.