Laravel 7 Vue JS CRUD Example Tutorial

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

In this Laravel 7 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. In this step by step tutorial I’ll demonstrate the implementation of simple crud application using Vue Js in laravel.

Laravel 7 Vue JS CRUD Example Tutorial

  • Download Laravel Apps
  • Configure Database Details
  • 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: Download Laravel Apps

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

Step 2: Configure Database Details

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

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

After installing all dependencies run this command:

Step 4: Create Migration, Model and Controller

Now, in this step we will create model and migration file along with controller 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 from app folder and update this code into Post.php model:

Next open PostController and define index, add, edit, delete methods in PostController file. So Go to app>Http>Controllers 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

Routes/Api.php

Step 6: Create Vue Js App

In this step, navigate to resources/views and create one folder named layouts. Inside this folder create one blade view file named app.blade.php file.

Next, Navigate to resources/views/layouts and open app.blade.php file. Then update 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:

  • App.vue
  • AllPost.vue
  • AddPost.vue
  • EditPost.vue

App.vue is the main Vue file. We will define router- view in the file. So all route pages will be shown in the App.vue file

Open App.vue file and update the following code into your file:

Next, Open AllPost.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

In this step you need to define vue routes. Lets 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: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 7 Vue JS CRUD Example Tutorial and its application with practical example. I hope you will like this tutorial.