Replies: 1 comment
-
Rather than extending the Product model I would suggest you instead use resolveRelationUsing in your app service provider. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi, After adding product add-ons into the products create/edit page with Slots, I just wanted to share my experince here for someone that he/she may need it too.
Creat ProductAddOns model
With that command we create ProductAddOns model and a migration file. for the migration we add three fields 'name, value and product_id':
And the ProductAddOns model:
In the boot method of the model, we make sure to prevent empty rows and duplicate rows for a product, so basically we let duplicate values in the table but not for the same product parent.
Now we extend the Lunar product model to add ProductAddOns relation:
Now we make the AddOns LiveWire component:
And the component view, I'm using Tailwind:
HINT: I coludn't use @livewire($slot->getName()) it didn't work for me?!!
And at the end we need to register both the Product model and the Livewire component in AppServiceProvider, We need to register the model to bind the Extended Product model with Lunar's Product model.
Beta Was this translation helpful? Give feedback.
All reactions