In this video we are going to learn about Show Selected Service Categories on Homepage.
So let see how can we Show Selected Service Categories on Homepage.
First of all lets add a new column in service_categories table.
For that lets create a new migration for adding the new column.
So switch to the command prompt and run the command

php artisan make:migration add_featured_to_service_categories_table --table= service_categories

Now switch to the project and lets open this migration and add following code.


use Illuminate\\Database\\Migrations\\Migration;
use Illuminate\\Database\\Schema\\Blueprint;
use Illuminate\\Support\\Facades\\Schema;

class AddFeaturedToServiceCategoriesTable extends Migration
* Run the migrations.
* @return void
public function up()
Schema::table('service_categories', function (Blueprint $table) {

* Reverse the migrations.
* @return void
public function down()
Schema::table('service_categories', function (Blueprint $table) {

Now lets migrate the migration.

php artisan migrate

Alright now run the application

php artisan serve

Now switch to the project and lets open the admin-edit-service-category-complonent.blade.php view file.
Now inside this file add the select control for featured service

<div class=\"form-group\">
<label for=\"featured\" class=\"control-label col-sm-3\">Featured: </label>
<div class=\"col-sm-9\">
<select class=\"form-control\" name=\"featured\" wire:model=\"featured\">
<option value=\"0\">No</option>
<option value=\"1\">Yes</option>

Now go to the AdminEditServiceCategoryComponent.php class file and add the property

public $featured;

Now inside the mount method add following code.

$this->featured = $ scategory >featured;

Now inside the updateServiceCategory method write following code.

$scategory->featured = $this->featured;

Now open the admin-service-sategory-component.blade.php view file and here lets display the featured column
So add following code inside the table.

//in table head section

//in table body seciton

Now lets check this
So switch to the browser and go to the all services page and you see the featured column.
Now lets make some serviceCategory featured.
So edit this and set featured yes then update.

Now lets open the HomeComponent.php Class file
And inside the render method write the following code

$fscecategories = ServiceCategory::where('featured',1)->inRandomOrder()->take(8)->get();

Now just return this $fscecategories to the component view
Now lets open the home-component.blade.php view file and the following code.

<div class=\"content_info\">
<div class=\"bg-dark color-white border-top\">
<div class=\"container\">
<div class=\"row\">
<div class=\"col-md-4 \">
<div class=\"services-lines-info\">
<h2>WELCOME TO SurfsideMedia</h2>
<p class=\"lead\">
Book best services at one place.
<span class=\"line\"></span>

<p>Find a wide variety of home services.</p>
<div class=\"col-md-8\">
<ul class=\"services-lines\">
@foreach($fscategories as $fscategory)
<a href=\"{{route('home.services_by_category',['category_slug'=>$fscategory->slug])}}\">
<div class=\"item-service-line\">
<i class=\"fa\"><img class=\"icon-img\"
src=\"{{ asset('images/categories') }}/{{$fscategory->image}}\"></i>

Now its done so lets check it.
So switch to the browser and refresh the page.
And on home page you can see here featured service categories.
So in this way you can show to selected service categories on homepage.