mercredi 18 mars 2020

Attach/sync multiple foreign keys in pivot table - Laravel

I am working on a project with has this kind of an model.

I have a Services table which contains the list of all the services:

services

id | name
---+----------------
1  |  S1
2  |  S2
3  |  S3

Then i have a Levels table:

levels

id | name
---+----------------
1  |  Entry
2  |  Professional
3  |  Executive

Then i have a deadlines table:

deadlines

id | name
---+----------------
1  |  1 Day
2  |  2 Day
3  |  3 Day

Packages table based on service, level and deadline IDs.

Packages (Pivot Table):

service_id  | deadline_id | level_id | price 
------------+-------------+----------+---------
   1        |     1       |     2    |   25.00
   1        |     1       |     1    |   24.00
   2        |     1       |     1    |   23.00

and so on ...

Suggest me the way to define relationship in this scenario or should I change my table structure to store this data?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire