i am calling a column from different table to display it in the current table like showing below:
DB::table('tbl_users')
->where('id', $complaints->user_id)
->limit(1)
->get('phone');
and this is the current output:
[{"phone":"0123456789"}]
how can i achieve the output to be like this:
0123456789
i tried to encode/decode and tried to wrap the whole query with json but none of that worked
UPDATE:
controller:
public function index()
{
$complaint = DB::table('complaint')->get();
$phone = DB::table('tbl_users')
->where('id', $complaint->user_id)
->select('phone')
->first();
return view('admin.complaints',compact('complaint','phone'));
}
Blade:
@foreach ($complaint as $complaints)
<tr>
<th style="padding: 20px">{{ $complaints->id }}</th>
<th style="padding: 20px">{{ $complaints->createdDate }}</th>
<th style="padding: 20px">New</th>
<th style="padding: 20px">{{ $complaints->user_id }}</th>
<th style="padding: 20px">{{$phone->phone}}</th>
</tr>
@endforeach