How can i get a count of the number of arrays of the attached screenshot. In this scenario the number i want is 2
public function update(Request $request, $jobId)
{
//dd($request);
// cast into a collection use the collect() helper
$collection = collect($request);
for ($i=0; $i < $collection->count(); $i++) {
//dd(count($request));
$subJob = SubJob::Find($request->get('id')[$i]);
$subJob->job_id = $jobId;
$subJob->name = $request->get('name')[$i];
$subJob->size = $request->get('size')[$i];
$subJob->medium = $request->get('medium')[$i];
$subJob->feature = $request->get('feature')[$i];
$subJob->qty = $request->get('qty')[$i];
$subJob->price = $request->get('price')[$i];
$subJob->total = $request->get('qty')[$i] * $request->get('price')[$i];
$subJob->save();
}
$collection->count() gives the value 9
Is there any other way of running the loop until the end? For example in blade we have $loop->last but here , i am working at the Controller level
<form action="{{ route('employee.subjob.update',$job->id) }}" method="post"><br>
@csrf
@method('PUT')
@foreach ($subJobs as $subJob)
<input type="hidden" name="id[]" value="{{$subJob->id}}">
<tr>
<td><input type="text" name="name[]" value="{{$subJob->name}}"></td>
<td><input type="text" name="size[]" value="{{$subJob->size}}"></td>
<td>
<textarea name="medium[]" rows="3" cols="20">{{$subJob->medium}}</textarea>
</td>
<td>
<textarea name="feature[]" rows="3" cols="20">{{$subJob->feature}}</textarea>
</td>
<td><input type="text" name="qty[]" value="{{$subJob->qty}}"></td>
<td><input type="text" name="price[]" value="{{$subJob->price}}"></td>
<td><input type="text" name="total[]" value="{{$subJob->total}}" disabled></td>
</tr>
@endforeach
<button type="submit" class="btn btn-primary"> Update Job No {{$job->id}}</button>
</form>

first()? laravel.com/docs/5.6/collections#method-first. In addition, your question is not clear as to what exactly you're trying to achieve