In this video we are going to learn about Create User Profile.
So let see how can we Create User Profile.
First of all lets create a model and migration for profile.
So switch to the command prompt and run the command.

php artisan make:model –m

Now switch to the project and lets open the create_profile_table migration.
In this migration lets add some columns.

<?php

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

class CreateProfilesTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('profiles', function (Blueprint $table) {
$table->id();
$table->bigInteger('user_id')->unsigned();
$table->string('image')->nullable();
$table->string('mobile')->nullable();
$table->string('line1')->nullable();
$table->string('line2')->nullable();
$table->string('city')->nullable();
$table->string('province')->nullable();
$table->string('country')->nullable();
$table->string('zipcode')->nullable();
$table->timestamps();
$table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
});
}

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


Now lets open the User model and here create a function.


public function profile()
{
return $this->hasOne(Profile::class,'user_id');
}


Now lets migrate this migration.
So switch to the command prompt and run the command.

php artisan migrate

Now lets create a new livewire component for user profile.

php artisan make:livewire user/UserProfileComponent

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

Route::get('/user/profile',UserProfileComponent::class)->name('user.profile');

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

<?php

namespace App\\Http\\Livewire\\User;

use App\\Models\\Profile;
use App\\Models\\User;
use Illuminate\\Support\\Facades\\Auth;
use Livewire\\Component;

class UserProfileComponent extends Component
{
public function render()
{
$userProfile = Profile::where('user_id',Auth::user()->id)->first();
if(!$userProfile)
{
$profile = new Profile();
$profile->user_id = Auth::user()->id;
$profile->save();
}
$user = User::find(Auth::user()->id);
return view('livewire.user.user-profile-component',['user'=>$user])->layout('layouts.base');
}
}


Now lets open the user-profile-component.blade.php view file and here lets display the user profile details.

<div>
<div class=\"container\" style=\"padding: 30px 0\">
<div class=\"row\">
<div class=\"panel panel-default\">
<div class=\"panel-heading\">
Profile
</div>
<div class=\"panel-body\">
<div class=\"col-md-4\">
@if($user->profile->image)
<img src=\"{{asset('assets/images/profile')}}/{{$user->profile->image}}\" width=\"100%\" />
@else
<img src=\"{{asset('assets/images/profile/default.jpg')}}\" width=\"100%\" />
@endif
</div>
<div class=\"col-md-8\">
<p><b>Name: </b>{{$user->name}}</p>
<p><b>Email: </b>{{$user->email}}</p>
<p><b>Phone: </b>{{$user->profile->mobile}}</p>
<hr>
<p><b>Line1: </b>{{$user->profile->line1}}</p>
<p><b>Line2: </b>{{$user->profile->line2}}</p>
<p><b>City: </b>{{$user->profile->city}}</p>
<p><b>Province: </b>{{$user->profile->province}}</p>
<p><b>Country: </b>{{$user->profile->country}}</p>
<p><b>Zip Code: </b>{{$user->profile->zipcode}}</p>
</div>
</div>
</div>
</div>
</div>
</div>


Now go to the project directory then open public folder then go inside the assets then images.
Inside the images directory create a new folder.
That is profile.
Now inside this folder lats add here a default profile image.
So go to the google and search profile dummy image.
Now download any one from these.
I have already downloaded this.
So lets copy this and paste inside the this profile directory Now lets open the base layout file.
Inside the user menu lets add here the link for user profile.

<li class=\"menu-item\" >
<a title=\"My Profile\" href=\"{{ route('user.profile') }}\">My Profile</a>
</li>



Now its done so lets check.
Switch to the browser and refresh the page.
Now go to the user menu and lets click on My Profile.
And here you can see the user profile.
So in this way you can Create User Profile.
In next video we will see how can we update the profile.