0

I have two models. A Product and a Variant. Both models have an attribute of short_description.

A Product has many Variants

A Variant belongs to a Product

On my variant resource, I have the following field

Textarea::make('Short Description', 'short_description')->nullable(),

Is there a way when creating a Variant using the Variant resource, to default the short description to use the product description? This will only be for creation as the variant short description could've been overwritten and at that point I would want to use the variant description over the product.

I've looked at ->withMeta() but can't see how I can check whether I am creating and whether the variant description already exists.

Community
  • 1
  • 1
jhine
  • 247
  • 1
  • 11
  • 1
    Are you creating the Variant via the `BelongsTo` field? Respectively navigating to a Products detail view and using "Create Variant"? Otherwise you won't have access to the product description ... – Volker Rose Mar 19 '20 at 11:11
  • 1
    Regarding the check for the create view, see my answer over at https://stackoverflow.com/a/60651503/341983. – Volker Rose Mar 19 '20 at 11:34

0 Answers0