Skip to content

Commit

Permalink
[fix] add teaser
Browse files Browse the repository at this point in the history
  • Loading branch information
diptarimba committed Oct 20, 2024
1 parent 9e97c18 commit 7c10920
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
11 changes: 10 additions & 1 deletion app/Http/Controllers/Admin/OrderController.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,21 @@ public function index(Request $request)
{
if($request->ajax())
{
$order = Order::select();
$order = Order::with('order_product.product')->select();
return datatables()->of($order)
->addIndexColumn()
->addColumn('created_at', function($query){
return $query->created_at->format('d F Y H:i:s');
})
->addColumn('product_sold', function($query){
$orderProducts = $query->order_product->take(4)->map(function($orderProduct) {
return $orderProduct->product->name . '(' . $orderProduct->quantity . ')';
});
if($orderProducts->count() < $query->order_product->count()){
$orderProducts->push('...');
}
return $orderProducts->implode(', ');
})
->addColumn('amount', function($query){
return '<div class="flex justify-between"><span>Rp.</span><span>'.number_format($query->amount, 0, '', '.').'</span></div>';
})
Expand Down
4 changes: 3 additions & 1 deletion resources/views/page/admin-dashboard/order/index.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@
<thead>
<tr>
<th class="p-4 pr-8 border rtl:border-l-0 border-y-2 border-gray-50 dark:border-zinc-600">Id</th>
<th class="p-4 pr-8 border border-y-2 border-gray-50 dark:border-zinc-600 border-l-0">Tanngal Transaksi
<th class="p-4 pr-8 border border-y-2 border-gray-50 dark:border-zinc-600 border-l-0">Tangal Transaksi
</th>
<th class="p-4 pr-8 border border-y-2 border-gray-50 dark:border-zinc-600 border-l-0">Product Terjual</th>
<th class="p-4 pr-8 border border-y-2 border-gray-50 dark:border-zinc-600 border-l-0">Jumlah</th>
<th class="p-4 pr-8 border border-y-2 border-gray-50 dark:border-zinc-600 border-l-0">Action</th>
</th>
Expand All @@ -32,6 +33,7 @@
@section('custom-footer')
<x-datatables.single url="{{ route('admin.order.index') }}" needrange="true">
<x-datatables.column name="created_at" />
<x-datatables.column name="product_sold" />
<x-datatables.column name="amount" />
<x-datatables.action />
</x-datatables.single>
Expand Down

0 comments on commit 7c10920

Please sign in to comment.