i'm using hasManyThrough eloquent relatoinship laravel, when i'm foreach data in view i got a mess output.
this is my output. https://ibb.co/jymR7GQ
Member model
public function rents()
{
return $this->belongsTo('App\Rent','member_id');
}
public function memberHistory()
{
return $this->hasManyThrough(
'App\RentDetail',
'App\Rent',
'member_id',
'rent_id',
'id',
'id',
);
}
}
RentDetail model
public function rent()
{
return $this->belongsTo('App\Rent','rent_id');
}
}
Rent model
public function users()
{
return $this->belongsTo('App\User', 'user_id');
}
public function members()
{
return $this->hasOne('App\Member','member_id');
}
public function books()
{
return $this->belongsTo('App\Book','book_id');
}
public function rentDetail()
{
return $this->hasMany('App\RentDetail','rent_id');
}
}
RentController
public function order()
{
$members = Member::all();
return view('rents.order',compact('members'));
}
}
Order View
@foreach($members as $v)
{{$v->memberHistory}}<br>
@endforeach
i want output similar like this https://ibb.co/L8QFMT5