I have 2 table 1st fund
2nd users
I have a registered member name in the table users
and a registered member in the fund
table user_id
. I want to show the username in a table where I can show it user_id
.
<div class="deposit-body">
<table class="table main-table">
<tbody>
<tr class="head">
<th>Name</th>
<th>Date</th>
<th>Currency</th>
<th>Amount</th>
</tr>
@foreachFund::with('user')->where('created_at', '>', Carbon::now()->subHours(24))->orderBy('id', 'desc')->take(10)->get()
<tr>
<td>{{ $fund->user_id }}</td>
<td>{{ $fund->updated_at}}</td>
<td><strong>{{$basic->currency}}</strong></td>
<td><strong>{{ $fund->total }}</strong></td>
</tr>
@endforeach
</tbody>
</table>
</div>
I applied the following code to my foundation model. But that does not work.
public function user(){
return $this->belongsTo('App\User', 'user_id');
}
source
share