In this video we are going to learn about Admin Fetch Services By Their Category
So let see how can we Admin Fetch Services By Their Category
First of all lets create a new livewire component so
Switch to the command prompt and lets create the new livewire component
So just type the command

php artisan make:livewire admin/AdminServicesByCategroyComponent

Now lets run the application

php artisan serve

Now switch to the project and lets create the route for this component
So go inside the routes directory then open web.php file
Now lets create here the new route inside the Admin Middleware route group


Now lets open AdminServicesByCategoryComponent class file and write the following codes


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

use App\\Models\\Service;
use App\\Models\\ServiceCategory;
use Livewire\\Component;
use Livewire\\WithPagination;

class AdminServicesByCategoryComponent extends Component
use WithPagination;
public $category_slug;

public function mount($category_slug)
$this->category_slug = $category_slug;

public function render()
$category = ServiceCategory::where('slug',$this->category_slug)->first();
$services = Service::where('service_category_id',$category->id)->paginate(10);
return view('livewire.admin.admin-services-by-category-component',['category_name'=>$category->name,'services'=>$services])->layout('layouts.base');

Now lets open the AdminServicesByCategroyComponent View file and inside this file write the following codes

nav svg{
height: 20px;
nav .hidden{
display: block !important;
<div class=\"section-title-01 honmob\">
<div class=\"bg_parallax image_02_parallax\"></div>
<div class=\"opacy_bg_02\">
<div class=\"container\">
<h1>{{$category_name}} Services</h1>
<div class=\"crumbs\">
<li><a href=\"/\">Home</a></li>
<li>{{$category_name}} Services</li>
<section class=\"content-central\">
<div class=\"content_info\">
<div class=\"paddings-mini\">
<div class=\"container\">
<div class=\"row portfolioContainer\">
<div class=\"col-md-12 profile1\">
<div class=\"panel panel-default\">
<div class=\"panel-heading\">
<div class=\"row\">
<div class=\"col-md-6\">
{{$category_name}} Service
<div class=\"col-md-6\">
<a href=\"#\" class=\"btn btn-info pull-right\">Add New</a>
<div class=\"panel-body\">
<div class=\"alert alert-success\" role=\"alert\">{{Session::get('message')}}</div>
<table class=\"table table-striped\">
<th>Created At</th>
@foreach($services as $service)
<td><img src=\"{{asset('images/services/thumbnails')}}/{{$service->thumbnail}}\" height=\"60\" /> </td>
<a href=\"#\"><i class=\"fa fa-edit fa-2x text-info\"></i></a>
<a href=\"#\" style=\"margin-left:10px;\"><i class=\"fa fa-times fa-2x text-danger\"></i></a>

Now lets open the admin-service-category-component view file and lets add the link here for sevices

<a href=\"{{route('admin.services_by_category',['category_slug'=>$scategory->slug])}}\" style=\"margin-right:10px \"><i class=\"fa fa-list fa-2x text-info\"></i></a>

Now all done so lets check it
So switch to the browser and refresh the page
Now you can see here the link for services
Lets click on any link
And here you can see the all services of this category
Lets check another category
So in this way you can fetch services by their Category