Support the ongoing development of Laravel.io →
posted 2 weeks ago
Laravel

maximos, gvsrepins liked this thread

2
moderator

Hello @maximos

If I understand your models correctly the additional fields that you want are requirements for the discount.

I should advice to create a model DiscountRequirement that contains the needed key/values. (And if you don't like that you can use a json column but I personal don't prefer that because you are missing the normalized value from your database)

If you want more validation you can also create a Discount type with required fields but I don't know if that is needed/wanted in your case.

Please tell me if it is clear or that you have more questions :)

And maybe you can write out a diagram to get a visible picture and documentation in one action. (like with mermaid, that is text that you can transform to an image) https://mermaid.js.org/syntax/entityRelationshipDiagram.html

maximos liked this reply

1

Thanks) I created custom pivot model and store additional fields for birthday discount in field birthday:

class DiscountPlace extends Pivot
{
    protected $casts = [
        'birthday' => 'object'
    ];
}

tvbeek liked this reply

1

Sign in to participate in this thread!

Eventy

Your banner here too?

Max maximos Joined 20 Apr 2016

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.