/* Image link */
https://drive.google.com/file/d/1um_MU26K58PzsEZBOWWOCxHkN836wJyD/view
In the above image I have a table with product name and stocks-In dates and total in.
On 1 October three stocks added , on 4 October 1 stock added and on 18 October 1 stock added.
Know I want to show only unique dates means 1 October date is repeating because on that day three stocks added, I want to show repeated dates once and the sum of their stocks in quantity below it. At the end I want to show the sum of all the stock in dates quantity in total in column.
/Database Image/
https://drive.google.com/file/d/17tT1X3aJlzpE3YwwIvNkDbxK-GbBuk25/view?usp=sharing
Controller code
public function render()
{
return view('livewire.reports.report-list', [
'stockins' => StockIn::oldest()->get(),
]);
}
view code
<table class="table table-bordered table-striped table-sm table-hover" id="product_table">
<thead class="table-dark">
<tr class="text-center">
<th scope="col">Name</th>
@foreach ($stockins as $stockin)
<th scope="col">{{ $stockin->created_at->format('d-M-Y') }}</th>
@endforeach
<th scope="col">Total IN</th>
</tr>
</thead>
<tbody>
<tr class="text-center">
@foreach ($stockins->unique('product_id') as $stockin)
<td>{{ $stockin->product->product_name }}</td>
@endforeach
@foreach ($stockins as $stockin)
<td>{{ $stockin->total_in }}</td>
@endforeach
</tr>
</tbody>
</table>