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)
$tempImage->image
@endforeach
if you want to get the 1st result you can do this in your view
$temps->->tempImage()->first()->image
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');
}
}
johnef liked this reply
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community