DEV Community

techdurjoy
techdurjoy

Posted on

Vue Laravel Crud Example with Sweet Alert

Vue Laravel CRUD is an important operation to learn laravel and vue from scratch. CRUD (Create, Read, Update, and Delete) are the primary data operations and one of the first things you learn as a Laravel developer.

We will learn how to build a small web application that creates, reads, updates, and deletes data from the MySQL database. We will learn how to create tables, controllers, views, models, API routes, and working with axios library to send a network request.

Laravel is PHP’s fastest growing Framework with scalability and flexibility.

Why use Laravel and Vue

Laravel is PHP’s by far robust Framework to work with. Creating crud boilerplate with Vue and Laravel is very easy. Vue.js is an excellent javascript frontend framework that provides routing, http supports, middleware supports, and also client-side data management library Vuex.

The Laravel community has produced a ton of valuable educational resources, including this one! In this tutorial, you’ll build a trivia game as two separate projects: a Laravel API and a Vue frontend (using vue-cli). This approach offers some significant benefits:

It enables you to separate the backend and frontend projects and deploy them independently using the different strategies and schedules for testing and deployment
We can deploy the frontend as the static application to a CDN and achieve virtually unlimited scaling for the fraction of a cost of hosting it together with the backend.
This approach also allows developers to work on just an API or just the frontend without needing access to a complete source code of the other part of a system (this is still possible to achieve if the projects are closely integrated, but it’s a bit of tough to set up) making it an exceptional architecture for large teams and projects.
Enter fullscreen mode Exit fullscreen mode

Vue Laravel CRUD Example

The standard approach of combining Vue and Laravel is to create Vue components and then drop them into your Blade files. But CRUD operation under this architecture will require a page refresh before they’re reflected in the UI.

For this vue laravel crud demo, we will not create separate projects for the frontend because Laravel provides the best support for Vue.js. So, we will build the Vue components inside the Laravel’s assets folder.

We will create a Single Page Application(SPA) using the Laravel and Vue.js. In this SPA, you can create a post, edit the post, read the post, and delete the post. We will create the Laravel API Backend.

Now, first, we need to install the Laravel application. So let us install a new Laravel by the following command.

Read this article from Here

Top comments (0)