I have a Post model with a public function image() { return $this->morphOne('App\Image', 'imageable'); }
But when I tinker with $post->image() it returns Illuminate\Database\Eloquent\Relations\MorphOne {#704}
I have to add "->first()" to actually get the Image object. How do I have $post->image() return the Image object?
This is the relationship on the Image object: public function imageable() { return $this->morphTo(); }
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire