在表中显示其他属性 - Laravel

My pivot table admin_user with additional attribute item_no. I am finding it hard to retrieve the additional attribute into my html table.

PS: i tried $admin->pivot->item_no in my table but i get an error trying to get a non-object

Admin

public function users()
    {
        return $this->belongsToMany('App\User')->withPivot('item_no')
        ->withTimestamps();
    }

admin_food

admin_id

user_id 

item_no

Controller

public function index()
     {
         $admins = Admin::where('id',1)->get();

         return view('index',compact('admins'));
     }

HTML

<table class="table" id="table"> 
<thead>
    <tr> 
    <th>Order No#</th>
    <th>Name</th>

    </tr>

</thead>
<tbody>
@foreach($admins as $admin)
<tr >
<td>{{$admin->name}}</td>

</tr>
@endforeach
</tbody>
</table>

You access the item_id by access the pivot property of the user/related model.

Your controller is returning a collection that has only one admin.

     $admins = Admin::where('id',1)->get();

admins will be a collection of 1 admin that has id = 1.

if this was on purpose, then you can access the item_id for every user related to this admin by this code:

@foreach($admins as $admin)
    @foreach($admin->users as $user)
        <tr>
            <td>{{$user->name}}</td>
            <td>{{$user->pivot->item_id}}</td>
        </tr>
    @endforeach
@endforeach

To simplify:

$admin = Amdin::first();
$item_id = $admin->users()->first()->pivot->item_id