<!-- $spo=Supplier::class -->
@use(App\Models\Supplier)
@use(Carbon\Carbon)

<div class="row">
	<div class="col-9">
		<table class="table table-sm">
			<thead>
			<tr>
				<th>Service Type</th>
				<th>User Name</th>
				<th>Password</th>
				<th>URL</th>
				<th>Last Connect</th>
				<th class="text-right">Offerings</th>
			</tr>
			</thead>

			<tbody>
			@foreach (Supplier::offeringTypes($spo) as $key => $offering)
				<tr>
					<th>{{ $offering->type }}</th>
					@if(Arr::get($spo->detail->connections,$key))
						<td>{{ Arr::get($spo->detail->connections,$key.'.user') }}</td>
						<td>{{ Arr::get($spo->detail->connections,$key.'.pass') }}</td>
						<td>{{ Arr::get($spo->detail->connections,$key.'.url') }}</td>
						<td>{{ Carbon::createFromFormat('Y-m-d',Arr::get($spo->detail->connections,$key.'.last'))->format('Y-m-d') }}</td>
						<td class="text-right">{{ number_format($offering->items->count()) }}</td>
					@else
						<td colspan="5">&nbsp;</td>
					@endif
				</tr>
			@endforeach
			</tbody>
		</table>
	</div>
</div>