Web Prepration

Web Concept Tutorials

Laravel, PHP

In this post, I am going to explain how to create CURD (Create,Update,Read and Delete) operation with image in laravel 5+ from scratch. This post is very helpful for laravel beginners. In this CRUD application just need to follow all steps. I used resource route, validation, listing etc in this crud application example.

After finish all step successfully, you will find output like as bellow image output.

Laravel Curd

Step 1: Laravel Installation

If you haven’t installed laravel in your system and want to fresh project then just run bellow command and get new Laravel project.

After clone laravel application, we also require to install laravelcollective/html for Form class,you can install laravelcollective/html class using composer just need to update composer.json file and add “laravelcollective/html”: “~5.0” in require section.

after that changes run below command.

Step 2: Create items table and model

In this step we have to create migration for items table using Laravel  php artisan command, so first fire bellow command:

After this command you will find one file in following path database/migrations and you have to put bellow code in your migration file for create items table

After create “items” table you should create Item model for items, so first create file in this path app/Item.php and put bellow content in item.php file:

Step 3: Configure database and migrate tables

Now we just need to create new database in phpmyadmin with any name  and then just change database configuration setting in .env file. There are three things are need to change like DB_DATABASE,DB_USERNAME and DB_PASSWORD. Then run below command.

Step 4: Add Route

Now we have to add route for items CRUD, in this example i added resource route for application, if we add resource route then it will add index, create, show, edit and delete route automatically. So add bellow line in your route file.

Step 5: Create Controller

Now we should create new controller as ItemCRUDController in this path app/Http/Controllers/ItemCRUDController.php. this controller will manage all route method, So add bellow line in your ItemCRUDController.php  file.

Step 6: Create Blade File

In this step we will create blade file for listing, create, edit and show records and also create default blade file for theme layout setting. So first we create new layouts directory and create default.blade.php file inside that folder

Now we will create layout for records listing, So first we create new ItemCRUD directory and create index.blade.php file inside that folder.

Now we create new blade file for create new record, it’s call create.blade.php file inside “ItemCRUD” directory

Next, we have to create show.blade.php file for record details page in same directory.

At last, we need to create edit.blade.php file for update record in same.

View Demo

Now everything is completed of laravel CURD application if you want to download of demo then click here. For other laravel  tutorials or queries you can follow my blog laravel category.


5 comments on Create CURD operation in Laravel

  • furtdsolinopv

    Wonderful work! That is the type of info that are meant to be shared around the web. Disgrace on the search engines for no longer positioning this publish upper! Come on over and consult with my site . Thank you =)

  • zvodretiluret

    Hiya, I am really glad I’ve found this information. Today bloggers publish only about gossips and net and this is actually frustrating. A good web site with interesting content, that is what I need. Thank you for keeping this website, I will be visiting it. Do you do newsletters? Cant find it.

Write a comment

Your email address will not be published.