I was under the impression that when I use a belongsTo relationship in my model, it will return the object but I seem to only get the id. Is this supposed to happen and what is the benefit of this?
This is my code:
From my Photo model
public function album()
{
return $this->belongsTo('Album', 'album');
}
And my PhotosController
$photo = Photo::find($id);
$album = $photo->album;
return 'albums/' . $album->folder . '/thumbs/' . $photo->file;
Don't mind the return, it's just for testing. I get an error:
Trying to get property of non-object
And a var_dump()
shows that all I get is a string with the album's id
$this->belongsTo('Album', 'local_key', 'parent_key');
– Erl