I have four tables in database and one Eloquent model for each table. Tables are:
How to retrieve items
from one category
and get collection of itemProperties
for each item
, so that when item
don't have all properties which category
have, the rest of properties exists in collection and values for that properties are empty strings or something like that?
For example:
in table category i have entry
- cats
in table category_properties i have entries
color of eyes
length of tail
shape of ears
In table items i have entry
- Garfield
and in item_properties I have only one entry
- green
related to Garfield in items table and color of eyes in category_properties.
How to get [ Garfield => [ 'color of eyes' => 'green', 'length of tail' => ' ', 'shape of ears' => ' ']]
, instead of [Garfield => [ 'color of eyes' => 'green']]
I can easily get expected results in mysql by joining tables item_properties and category_properties, but i don't know how to do the same with Eloquent and Laravel collections.
Is there something similar to sql join in eloquent?