Laravel is world famous php framework.we are going to talk about laravel 8 image uploading and display the image. it has various features.Laravel is a MVC architecture. In this tutorial will see how to make a Image Uploading and Display the image in Laravel 8. Here is the Best Place to Learn Laravel 8.
Install Laravel 8
Create a new Project type the command on the command prompt . I create the project name payroll
Laravel 8 Tutorial Setup the Project
composer create-project --prefer-dist laravel/laravel payroll
After Type the Command you have to wait till the project has been created.
Database setup
Create the Database on xampp which name is dbpayroll
After created the database.
Change .env File
Change .env File for username, password and DB Name
After that run check the application the welcome screen of Laravel framework look like this.
php artisan serve
Create Migration
Create the tables
php artisan make:migration create_employees_table
Click and open it.
inside the function up() function i shown in below clearly.
public function up() { Schema::create('employees', function (Blueprint $table) { $table->id(); $table->string('name'); $table->string('address'); $table->string('mobile'); $table->string('photo', 300); $table->timestamps(); }); } public function down() { Schema::dropIfExists('employees'); }
After add the lines type
php artisan migrate
Create Controller
Create the controller name which is EmployeeController
php artisan make:controller EmployeeController --resource
Create Model
Model is used to get the data from the database.
Create the Model name which is Employee
php artisan make:model Employee
After Model is Created the look like this. Code inside Model Class (app\Models\)