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

php artisan make:migration add_featured_to_services_table --table= services

Now switch to the project and lets open this migration.
And in this migration add a column so write the following code.

<?php

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

class AddFeaturedToServicesTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('services', function (Blueprint $table) {
$table->boolean('featured')->default(false);
});
}

/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('services', function (Blueprint $table) {
$table->dropColumn('featured');
});
}
}


Now lets migrate the migration, go to the command prompt and type command.

php artisan migrate


now run the application so run the command

php artisan serve

Aliright now run the application and switch to the project.
Lets open the admin-edit-service-component.blade.php view file and here add the select control for featured service

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


Now go to the AdminEditServiceComponent.php Class file and add the property

public $featured;

Now inside the mount method add the following code

$this->featured = $service->featured;


Now inside the updateService method add the following code.

$service->featured = $this->featured;


After this lets open the sdmin-service-component.blade.php view file and here lets display the featured column.
So add following code inside the table.


//in table head section
<th>Featured</th>

//in table body seciton
<td>
@if($service->featured)
Yes
@else
No
@endif
</td>


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 services featured.
So edit the product and set featured yes.
Now lets open the HomeComponent.php Class file.
And inside the render method just write the following code.

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


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

<div class=\"content_info\">
<div>
<div class=\"container\">
<div class=\"row\">
<div class=\"titles\">
<h2>SurfsideMedia <span>Choice</span> of Services</h2>
<i class=\"fa fa-plane\"></i>
<hr class=\"tall\">
</div>
</div>
<div class=\"portfolioContainer\" style=\"margin-top: -50px;\">
@foreach($fservices as $service)
<div class=\"col-xs-6 col-sm-4 col-md-3 hsgrids\"
style=\"padding-right: 5px;padding-left: 5px;\">
<a class=\"g-list\" href=\"{{route('home.service_details',['service_slug'=>$service->slug])}}\">
<div class=\"img-hover\">
<img src=\"{{ asset('images/services/thumbnails') }}/{{$service->thumbnail}}\" alt=\"{{$service->name}}\"
class=\"img-responsive\">
</div>
<div class=\"info-gallery\">
<h3>{{$service->name}}</h3>
<hr class=\"separator\">
<p>{{$service->tagline}}</p>
<div class=\"content-btn\"><a href=\"{{route('home.service_details',['service_slug'=>$service->slug])}}\"
class=\"btn btn-primary\">Book Now</a></div>
<div class=\"price\"><span>$</span><b>From</b>${{$service->price}}</div>
</div>
</a>
</div>
@endforeach
</div>
</div>
</div>
</div>


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 services.
So in this way you can show to selected services on homepage.