Support the ongoing development of →
Database Eloquent
Last updated 2 years ago.

Because you've got many TemplateImage for one Template, you need to iterate over the Temp object in your view. like this...

@foreach($temps->tempImage() as $tempImage)

if you want to get the 1st result you can do this in your view


And in your TempImage, you 've got a fonction which have the same name in the Template model, in the templaimage, you get the template model so i think this function must be named temp() (its the inverse relation) :

class TemplateImage extends Model
public function temp ()
        return $this->belongsTo('App\Models\Template', 'template_id');
Last updated 7 years ago.

johnef liked this reply


Sign in to participate in this thread!


Your banner here too?

johnef johnef Joined 18 May 2016


We'd like to thank these amazing companies for supporting us

Your logo here?

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 - All rights reserved.