So I have 2 model, item and images
Item has a column called "images" which has an unique ID "123"
Images has a column called "link_id" which has the unique ID of item.
There can be multiple images with the same link_id
in my item model i have this relationship set up
function images()
{
return $this->hasMany('App\Models\Image', 'link_id', 'images');
}
in my images model i have
function item()
{
return $this->belongsTo('App\Models\Item', 'images', 'link_id')- >first();
}
However when i do $item->images, there is nothing....
Am I doing something wrong? I have followed the docs on http://ift.tt/1TWqPCt
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire