Laravel 8 Vue JS CRUD Tutorial

In this tutorial you will learn about the Laravel 8 Vue JS CRUD Tutorial and its application with practical example.

In this Laravel 8 Vue JS CRUD Example Tutorial, I’ll show you how to create simple crud application using Vue Js in laravel. In this tutorial you will learn to create basic crud application with Vue Js in laravel 8. In this step by step tutorial I’ll demonstrate the implementation of simple crud application using Vue Js in laravel 8.

Laravel 8 Vue JS CRUD Tutorial

In this step by step guide, we will be creating a simple crud operation application with validation in laravel 8. In this example you will learn how to insert, read, update and delete data from database in laravel 8.

  • Install 8 Laravel 8 App
  • Connecting App to Database
  • Install NPM Dependencies
  • Create Migration, Model and Controller
  • Define Routes In web.php
  • Create Vue Js App
  • Create Vue Js Components For Crud App
  • Define Vue Js Routes For Crud App
  • Include Vue Js Dependencies to app.js
  • Run Development Server

Step 1: Install 8 Laravel 8 App

First of all we need to create a fresh laravel project, download and install Laravel using the below command

Step 2: Connecting App to Database

Now, lets create a MySQL database and connect it with laravel application. After creating database we need to set database credential in application’s .env file.

Step 3: Install NPM Dependencies

Now, you need to setup Vue Js In Laravel 8 and install Vue Js dependencies using NPM. So execute the following command on command prompt.

Now, install vue-router and vue-axios. vue-axios will be used for calling Laravel API. execute the following command on your command prompt:

After installing all dependencies execute this command on terminal:

Step 4: Create Migration, Model and Controller

Now, in this step we will create model and migration file. Please run the following command:

Now open create_posts_table.php migration file from database>migrations and replace up() function with this:create_posts_table.php

Now, run the migration to create database table using following artisan command:


Now, Open Post.php model file, which is placed inside app/models directory and update the code into Post.php model:

Now run following command to create PostController.php file:

Next open PostController and define index, add, edit, delete methods in PostController file. So Go to app>Http>Controllers>API folder and open PostController.php file. Then update the following method into this:

Step 5: Define Routes in Web.php

After this, we need to define routes in “routes/web.php” file. Lets open “routes/web.php” file and add the following routes in it.

routes/web.php

After this, we need to define routes in “routes/api.php” file. Lets open “routes/api.php” file and add the following routes in it.

routes/api.php

Step 6: Create Vue Js App

In this step we will create Vue Js app, go to resources/views and create one folder named layouts. Inside this folder create a blade view file named app.blade.php file.

Now, go to resources/views/layouts and open app.blade.php file. Then put the following code into your app.blade.php file as follow:

Step 7: Create Vue Js Components For Crud App

In this step, go to resources>js folder and create the following vue js component files:

Here, App.vue would be the main Vue file. Lets define router- view in the file. Now all route pages will be displayed on the App.vue file. Go to App.vue file and put the following code into your file:

Next, Open AllPosts.vue file and update the following code into your file:


Next, Open AddPost.vue file and update the following code into your file:


Next, Open EditPost.vue file and update the following code into your file:

Step 8: Define Vue Js Routes For Crud App

Now, you need to define vue routes. So go to resources>js folder, create a file named routes.js and update the following routes into your routes.js file:

Step 9: Include Vue Js Dependencies to app.js

Now, you need to add all routes, vue axios and other dependencies etc. So Go to resources>js folder and open app.js. Then update the following code into your app.js file:

Step 10: Run Development Server

Now we are ready to run our example so lets start the development server using following artisan command –

In this tutorial we have learn about the Laravel 8 Vue JS CRUD Tutorial and its application with practical example. I hope you will like this tutorial.