Celebrating 10 years in web hosting [email protected]

In this article, we are going to learn about Laravel 8 crud step by step. I will describe it properly by dividing it into six steps. In these steps, I will let you know that how to create a crud application in Laravel 8. You will learn about the crud process in Laravel 8

There is a need to follow the six steps for creating for example of the Laravel 8 crud application.

Generally, Laravel 8 includes many new features including Laravel Jetstream, a models directory, etc.,

Laravel 8 provides a lot of new features and LTS support. Moreover, if you are new to Laravel then this explanation will be going to help you the most to create an insert update delete application in Laravel 8 crud.

Similarly, before installing the Laravel you also think about what packages are you need to install in your system if you want to install Laravel 8 you should install PHP 7.3 version and above something you can install.

First Install Laravel 8

First, we need to install Laravel so for downloading Laravel use the command below open your command prompt or terminal and write the command there:

Composer create-project –prefer-dist Laravel/Laravel blog.

Second, make database configuration

Make database configuration in this step for the example database name, username, password, etc. for the crud application of Laravel 8. You can do this by opening the .env file and filling in the details.

Third, create a migration

Now we are going to create a crud application for the product.

Also, there is a need to create migration for the “products” table with the help of the Laravel 8 PHP artisan command, first type the command that is below

PHP artisan make:migration create_products_table –create=products

After that when you type the command you will find one file in the following path “database/migrations” and especially there is a need to write the code that is below in your migration file to create a products table.

laravel 8 Crud

Run this migration by using the “PHP artisan migrate “command.

Fourth Add Resource Route

Therefore add resource route for product crud application. So then open your “routes/web.php” file and type the following route.

Laravel 8 Crud for command

Fifth make Controller and Model

There is a need to create a new controller as ProductController. Especially for doing this run the below command and create a new controller.

PHP artisan make:controller ProductController –resource –model=Product

After that, you will see a new file in this path “app/Http/Controllers/ProductController. PHP”.

In this controller, we will create seven methods:

  • index()
  • edit()
  • update()
  • create()
  • show()
  • destroy()
  • store()

Let’s copy the code and put it on the” ProductController.php” file.

Crud install

After that, you will find “app/Models/Product.php” and put the content in the Product.php file.

Crud lara

Sixth Add Blade Files

In this last step. Now there is just a need to create just blade files.

So that we mainly have to create layout files and then create new folder “products” then just create blade files of the crud app.

You just have to create the below blade files.

  • blade.php
  • blade.php
  • blade.php
  • blade.php
  • blade.php

Now let’s just create the following file like” resources/views/products/show.blade.php” and so on like this format.

Therefore you are ready to run your crud application for example with Laravel 8.

Use the below command for quick running.

“PHP artisan serve”

However, You can open the URL on the browser.