MYHOSPITALNOW.COM

Find Trusted Doctors & Hospitals

Discover healthcare providers, compare hospitals, and explore treatment options worldwide.

Free Treatment Quotes • Doctor Search • Hospital Comparison

Find Healthcare Options

www.myhospitalnow.com

How to set a Default image of the user’s profile image in the Laravel PHP Framework?

How to set a Default image of the user’s profile image in the Laravel PHP Framework?

Click Upload Profile Image.

Click Remove Old Profile Image.

Step 1. Create a new Project in Laravel, so open git bash. Write down the following command:-

$  composer create-project --prefer-dist laravel/laravel defaultimage "5.8.*"Code language: JavaScript (javascript)
Git Bash running composer create-project to create the Laravel 5.8 defaultimage project

Step 2. Move to project directory on git Bash, so write down the following command:-


$ cd defaultimage
Git Bash running cd defaultimage to enter the new Laravel project directory
Mysql Database connection Laravel

Step 3.  So, Create a Database for this and Go to XAMPP server->phpMyAdmin->Click New Database->defaultimage.

PhpMyAdmin Databases tab creating a new database named defaultimage

Step 4. Go to .env file to set the project path and give the project APP_URL, DB_DATABASE name and DB_USERNAME name.

APP_URL=http://localhost/defaultimage/public
DB_DATABASE=defaultimage
DB_USERNAME=rootCode language: JavaScript (javascript)

Step 5. Create the user authentication scaffolding and write down the following command:-

$ php artisan make:auth
Git Bash running php artisan make:auth in the defaultimage project
Run Project URL
Laravel default welcome page with Login and Register links after running the project URL

Step 6. Add image column with default value into database/migrations/create_users_table.php.

$table->string('image')->default('user.png');Code language: PHP (php)
public function up()
    {
        Schema::create('users', function (Blueprint $table) {
            $table->bigIncrements('id');
            $table->string('name');
            $table->string('email')->unique();
            $table->string('image')->default('user.png');
            $table->timestamp('email_verified_at')->nullable();
            $table->string('password');
            $table->rememberToken();
            $table->timestamps();
        });
    }Code language: PHP (php)

Step 7. Now, Migrate the tables into the MySQL database. Write the following command in git Base.

$ php artisan migrate
Git Bash running php artisan migrate in the defaultimage project

Step 8. Now, Go to User.php file and write down the following code:-

Step 9. First of all, Link the storage directory. Write the following command:-

$ php artisan storage:link
Git Bash output: migrations completed and php artisan storage:link linked the public/storage directory

Step 10. Now, Create images folder and store default image file. C:\xampp\htdocs\defaultimage\public\storage\images.

File Explorer showing default user.png in defaultimage\public\storage\images folder

Step 11. After that, Go to layouts/app.blade.php file and write down the following code:-

Sublime Text app.blade.php with img tag showing the logged-in user's profile image in the navbar
Run Project URL
Laravel dashboard showing You are logged in with the default profile avatar beside user name Usha Kiran

Find Trusted Cardiac Hospitals

Compare heart hospitals by city and services — all in one place.

Explore Hospitals
With MotoShare.in, you can book a bike instantly, enjoy doorstep delivery, and ride without worries. Perfect for travelers, professionals, and adventure enthusiasts looking for a seamless mobility solution.

Related Posts

How to display a table in a Verticle or Horizontal form in the Laravel PHP Framework? Part-1

How to display a table in a Verticle or Horizontal form in the Laravel PHP Framework? How to Store Seed file into Database. Click There are two…

Read More

How to file upload in DB With local folder using laravel 5.8

Step:1 you have to make these(A) – php artisan make:controller ImageUploadController(B) – php artisan make:model ImageUpload -m Step:2 Open the welcome.blade.php page then write this code. Step:3…

Read More

How to store and retrieve image from the database in Laravel.

# Creating Migration For Uploading Image We need to add three lines in our migration file which makes column in our Database .After adding, run Migration ….

Read More

Laravel breeze vs laravel fortify comparison

Here’s a comparison table between Laravel Breeze and Laravel Fortify to help you understand their differences and choose the right tool for your project: Feature Laravel Breeze…

Read More

What is Laravel and use cases of Laravel?

What is Laravel? Laravel is an open-source, free PHP web framework designed for the development of web applications following the model-view-controller (MVC) architectural pattern. It was generated…

Read More

Laravel Tutorials: PHP Templating using Blade

Rajesh Kumar I’m Rajesh Kumar, a DevOps, SRE, DevSecOps, Cloud, and Platform Engineering expert passionate about sharing practical knowledge, real-world experiences, and industry best practices. I have…

Read More