The source code is on github bitfumes/api
- The purpose of these notes are to follow the above tutorial, making detailed notes of each step.
- They are not verbatim of the original video.
The source code is on github bitfumes/api
Source: https://medium.com/@Mahmoud_Zalt/eloquent-relationships-cheat-sheet-5155498c209
One to one ( 1-1 ) |
One to many ( 1-n ) |
Poly one to many ( 1x-n ) |
Many to many ( n-n ) |
Poly many to many ( nx-n ) |
|
---|---|---|---|---|---|
Number of models | 2 only | 2 only | 3 and above | 2 only | 3 and above |
Number of tables | 2 (1/model) | 2 (1/model) | 3+ (1/model) | 3 (1/model + pivot) | 4+ (1/model + pivot) |
Pivot table | - | - | - | required |
SET @entityid = 5; -- category's ID | |
-- Select varchar/string based category attribute values | |
SELECT ea.attribute_id, ea.attribute_code, eav.value AS 'value', 'varchar' AS 'type' | |
FROM catalog_category_entity e | |
JOIN catalog_category_entity_varchar eav ON e.entity_id = eav.entity_id | |
JOIN eav_attribute ea ON eav.attribute_id = ea.attribute_id | |
WHERE e.entity_id = @entityid | |
-- Select integer based category attribute values (includes boolean values) | |
UNION( |