Example of Pivot tables with extra fields in Loydtafireyi/ZimCart-Laravel-Ecommerce

File app/Order.php (link to Github)
use Illuminate\Database\Eloquent\Model;

class Order extends Model
{
    //
     public function products()
    {
    	return $this->belongsToMany(Product::class)->withPivot('quantity');
    }
}
File resources/views/admin/orders/show.blade.php (link to Github)
//
					@foreach($products as $p)
					<tr>
						<td>{{$p->code}}</td>
						<td>{{$p->name}}</td>
						<td>{{$p->price}}</td>
						<td>{{$p->pivot->quantity}}</td>
					</tr>
					@endforeach
//