In this video we are going to learn about Show Orders in Admin Panel.
So let see how can we can we show orders in admin panel.
So first of all lets create a component for Orders
So switch to the command prompt and lets create the new livewire component.
So just run the command.


php artisan make:livewire admin/AdminOrderComponent


Now run the application


php artisan serve


And switch to project and now lets create the route for this component
So go inside the routes directory and then open web.php file.
Inside the admin middleware group route

Route::get('/admin/orders',AdminOrderComponent::class)->name('admin.orders');


Alright now lets open the AdminOrderComponent.php class file write the following code.

<?php

namespace App\\Http\\Livewire\\Admin;

use App\\Models\\Order;
use Livewire\\Component;

class AdminOrderComponent extends Component
{
public function render()
{
$orders = Order::orderBy('created_at','DESC')->paginate(12);
return view('livewire.admin.admin-order-component',['orders'=>$orders])->layout('layouts.base');
}
}


Allright now open the admin-order-component.blade.php view file and the following code.

<div>
<style>
nav svg{
height: 20px;
}
nav .hidden{
display: block !important;
}
</style>

<div class=\"container\" style=\"padding: 30px 0;\">
<div class=\"row\">
<div class=\"col-md-12\">
<div class=\"panel panel-default\">
<div class=\"panel-heading\">
All Orders
</div>
<div class=\"panel-body\">
@if(Session::has('order_message'))
<div class=\"alert alert-success\" role=\"alert\">{{Session::get('order_message')}}</div>
@endif
<table class=\"table table-striped\">
<thead>
<tr>
<th>OrderId</th>
<th>Subtotal</th>
<th>Discount</th>
<th>Tax</th>
<th>Total</th>
<th>First Name</th>
<th>Last Name</th>
<th>Mobile</th>
<th>Email</th>
<th>Zipcode</th>
<th>Status</th>
<th>Order Date</th>
<th colspan=\"2\" class=\"text-center\">Action</th>
</tr>
</thead>
<tbody>
@foreach ($orders as $order)
<tr>
<td>{{$order->id}}</td>
<td>${{$order->subtotal}}</td>
<td>${{$order->discount}}</td>
<td>${{$order->tax}}</td>
<td>${{$order->total}}</td>
<td>{{$order->firstname}}</td>
<td>{{$order->lastname}}</td>
<td>{{$order->mobile}}</td>
<td>{{$order->email}}</td>
<td>{{$order->zipcode}}</td>
<td>{{$order->status}}</td>
<td>{{$order->created_at}}</td>
<td><a href=\"{{route('admin.orderdetails',['order_id'=>$order->id])}}\" class=\"btn btn-info btn-sm\">Details</a></td>
<td></td>
</tr>
@endforeach
</tbody>
</table>
{{$orders->links()}}
</div>
</div>
</div>
</div>
</div>
</div>




Now open the base.blade.php layout file
lets add here the link for orders inside the admin menu.

<li class=\"menu-item\">
<a title=\"All Orders\" href=\"{{route('admin.orders')}}\">All Orders</a>
</li>


Now its done so lets check it.
So switch to the browser and refresh the page.
No go inside the admin menu and here you will see the All Orders link.
Now just click on this link.
And here you will see all orders.
So in this way you can show orders in admin panel.