In this video we are going to learn about Create Service Provider's Profile.
So let see how can we Create Service Provider's Profile.
First of all lets create model.
So switch to the command prompt and run the command.

php artisan make:migration ServiceProvider –m

Now switch to the project and lets open the migration.
So go inside the database directory then migration.
and from here lets open this create_service_providers_table migration.
Now here lets add columns as following.

<?php

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

class CreateServiceProvidersTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('service_providers', function (Blueprint $table) {
$table->id();
$table->bigInteger('user_id')->unsigned();
$table->string('image')->nullable();
$table->string('about')->nullable();
$table->string('city')->nullable();
$table->bigInteger('service_category_id')->unsigned()->nullable();
$table->string('service_locations')->nullable();
$table->timestamps();
$table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
$table->foreign('service_category_id')->references('id')->on('service_categories')->onDelete('cascade');
});
}

/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('service_providers');
}
}



Now lets open the ServiceProvider model and here lets add the fillable and also create a function for category as following.


<?php

namespace App\\Models;

use Illuminate\\Database\\Eloquent\\Factories\\HasFactory;
use Illuminate\\Database\\Eloquent\\Model;

class ServiceProvider extends Model
{
use HasFactory;

protected $fillable = ['user_id'];

public function category()
{
return $this->belongsTo(ServiceCategory::class,'service_category_id');
}

public function user()
{
return $this->belongsTo(User::class,'user_id');
}
}


Alright now lets migrate the migration.
So switch to the command prompt and run the command.

php artisan migrate

Now switch to the project and go inside the app/Actions/Fortify.
From here lets open CreateNewUser.php file and make changes in create function as following.


public function create(array $input)
{
Validator::make($input, [
'name' => ['required', 'string', 'max:255'],
'email' => ['required', 'string', 'email', 'max:255', 'unique:users'],
'password' => $this->passwordRules(),
'phone' => ['required'],
'terms' => Jetstream::hasTermsAndPrivacyPolicyFeature() ? ['required', 'accepted'] : '',
])->validate();

$registeras = $input['registeras'] === 'SVP' ? 'SVP':'CST';

$user = User::create([
'name' => $input['name'],
'email' => $input['email'],
'password' => Hash::make($input['password']),
'phone' => $input['phone'],
'utype'=>$registeras
]);

if($registeras === 'SVP')
{
ServiceProvider::create([
'user_id' => $user->id
]);
}

return $user;
}


Now lets create a new livewire component.
So go to the command prompt and run the command.

php artisan make:livewire Sprovider/SproviderProfileComponent

Now run the application.

php artisan serve

Now switch to the project and lets create route for this.
So lets open the web.php file and inside the ServiceProvider middleware route group add new route.

Route::get('/sprovider/profile',SproviderProfileComponent::class)->name('sprovider.profile');


Now lets open SproviderProfileComponent.php class file and here lets write the following code.

<?php

namespace App\\Http\\Livewire\\Sprovider;

use App\\Models\\ServiceProvider;
use Illuminate\\Support\\Facades\\Auth;
use Livewire\\Component;

class SproviderProfileComponent extends Component
{
public function render()
{
$sprovider = ServiceProvider::where('user_id',Auth::user()->id)->first();
return view('livewire.sprovider.sprovider-profile-component',['sprovider'=>$sprovider])->layout('layouts.base');
}
}


Now lets open the sprovider-profile-component.blade.php view file and here write the following code.

<div>
<div class=\"section-title-01 honmob\">
<div class=\"bg_parallax image_02_parallax\"></div>
<div class=\"opacy_bg_02\">
<div class=\"container\">
<h1>Profile</h1>
<div class=\"crumbs\">
<ul>
<li><a href=\"/\">Home</a></li>
<li>/</li>
<li>Profile</li>
</ul>
</div>
</div>
</div>
</div>
<section class=\"content-central\">
<div class=\"content_info\">
<div class=\"paddings-mini\">
<div class=\"container\">
<div class=\"row portfolioContainer\">
<div class=\"col-md-8 col-md-offset-2 profile1\">
<div class=\"panel panel-default\">
<div class=\"panel-heading\">
<div class=\"row\">
<div class=\"col-md-6\">
Profile
</div>
<div class=\"col-md-6\">

</div>
</div>
</div>
<div class=\"panel-body\">
<div class=\"row\">
<div class=\"col-md-4\">
@if($sprovider->image)
<img src=\"{{asset('images/sproviders')}}/{{$sprovider->image}}\" width=\"100%\" />
@else
<img src=\"{{asset('images/sproviders/default.jpg')}}\" width=\"100%\" />
@endif
</div>
<div class=\"col-md-8\">
<h3>Name : {{Auth::user()->name}}</h3>
<p>{{$sprovider->about}}</p>
<p><b>Email: </b>{{Auth::user()->email}}</p>
<p><b>Phone: </b>{{Auth::user()->phone}}</p>
<p><b>City : </b>{{$sprovider->city}}</p>
<p><b>Service Category : </b>
@if($sprovider->service_category_id)
{{$sprovider->category->name}}
@endif
</p>
<p><b>Service Locations :</b> {{$sprovider->service_locations}}</p>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</section>
</div>


Now go to the project directory and then go inside the public directory.
Then images and here lets create a new folder and keep the name of folder sproviders.
Now lets paste here a default image for sprovider so go to the google and here serarch profile dummy image.
from here lets download any image and paste inside the sproviders directory.
So I have already download one.
So lets copy this and paste here.
Now go to the base.blade.php layout file and here inside the service providers menu lets add a link for Profile.

<li><a href=\"{{route('sprovider.profile')}}\">Profile</a></li>

Now its done so lets check it.
So switch to the browser and refresh the page.
Now lets register a new user as service provider.
So click on register now enter the user details here.
Now service provider created now go to service provider menu and click on profile.
Now here you can see the service provider profile.
So in this way you can Create Service Provider Profile.
In next video we will see how can we update the service provider profile.