Category Archives: Laravel

Laravel Tutorials

How to Create Custom Route File in Laravel App

How to Create Custom Route File in Laravel App

In this How to Create Custom Route File in Laravel App tutorial I’ll show you how to create custom route file in laravel. In this tutorial you will learn to create custom route file in your laravel project. In this step by step tutorial I’ll guide you through the process of creating custom route file in laravel.

Step 1: Install Laravel Fresh Application

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

Step 2: Create Custom Route File

In this step we will be creating custom route file. Go to appName/routes folder and create custom routes file. And will create custom routes file name students.php.

routes/student.php

Step 3: Add Files to ServiceProvider

In this step, you need to register your custom routes in Route Service Provider. Go to app/Providers folder and find RouteServiceProvider.php . Open it and register your custom routes file as follow:

Now you can add your routes in student.php route file and use it as follow:

Laravel 7 Vue JS CRUD Example Tutorial

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 –

Laravel 7 Generate PDF with Graph

In this Laravel 7 Generate PDF with Graph tutorial, I’ll show you how to generate pdf with graph in laravel. In this tutorial you will learn to generate pdf file with graph in laravel.

Laravel 7 Generate PDF with Graph

  • Step 1: Install wkhtmltopdf Software
  • Step 2: Download Laravel Fresh App
  • Step 3: Install mikehaertl/phpwkhtmltopdf
  • Step 4: Add Routes
  • Step 5: Create Controller by Command
  • Step 6: Create Blade View
  • Step 7: Run Development Server

Step 1: Install wkhtmltopdf Software

In thi step we will first install wkhtmltopdf software. Follow the instruction given below to install:

For Ubuntu:

for Windows:

You have go the following link and download exe. Then install it:

Step 2: Download Laravel Fresh App

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

Step 3: Install mikehaertl/phpwkhtmltopdf

In this step, we will install mikehaertl/phpwkhtmltopdf Package via the composer dependency manager. Use the following command to install mikehaertl/phpwkhtmltopdf Package.

Step 4: Add Routes

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

 

Step 5: Create Controller by Command

Now, lets create a controller named GraphPdfController using command given below –

This command will create a controller that name GraphPdfController.php.

Next go to app/Http/Controllers and open GraphPdfController.php. Then update the following methods into your controller file:

Step 6: Create View File

Go to resources/views/ folder and create a new blade view file that name graph.blade.php file.

After that, update the following code into your graph.blade.php file:

Step 7: Run Development Server

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

Now, open the following URL in browser to see the output –

Laravel 7 Vue JS File Upload Example

In this Laravel 7 Vue JS File Upload Example tutorial, I’ll show you how to upload file using Vue Js in laravel. In this tutorial you will learn to create file upload functionality using Vue Js in laravel.

Laravel 7 Vue JS File Upload Example

  • Step 1: Download Laravel Fresh App
  • Step 2: Add Database Detail
  • Step 3: Create Model And Migration
  • Step 4: NPM Configuration
  • Step 5: Add Routes
  • Step 6: Create Controller By Command
  • Step 7: Create Vue Component
  • Step 8: Register Vue App
  • Step 9: Run Development Server

Step 1: Download Laravel Fresh App

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

Step 2: Add 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: Create Model And Migration

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

This command will create one model name photo.php and also create one migration file for the photos table.

Now open create_photos_table.php migration file from database>migrations and replace up() function with following code:

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

Step 4: NPM Configuration

Install all Vue dependencies:

Step 5: Add Routes

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

Step 6: Create Controller By Command

Now, lets create a controller named FileUploadController using command given below –

After that, go to app\Http\Controllers and open FileUploadController.php file. Then update the following code into your FileUploadController.php file:

Step 7: Create Vue Component

Next step, go to resources/assets/js/components folder and create a filed called FileUpload.vue.

And update the following code into your FileUpload.vue components file:

Now open resources/assets/js/app.js and include the FileUpload.vue component like this:app.js

Step 8: Register Vue App

In this step, we will create a blade view file to define Vue’s app. Go to resources/views folder and make a file named upload.blade.php. Then update the following code into upload.blade.php as follow:

Step 9: Run Development Server

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

Laravel 7 Vue Dependent Dropdown Example

In this Laravel 7 Vue Dependent Dropdown Example tutorial, I’ll show you how to create dependent dropdown with Vue Js in laravel. In this tutorial you will learn to implement dependent dropdown with Vue Js in laravel. In this tutorial we will be creating simple country dependent dropdown to demonstrate dependent dropdown example in laravel.

Laravel 7 Vue Dependent Dropdown Example

  • Step 1: Download Laravel Fresh App
  • Step 2: Add Database Detail
  • Step 3: Create Migration Files
  • Step 4: Create Models
  • Step 5: NPM Configuration
  • Step 6: Add Routes
  • Step 7: Create Controller By Command
  • Step 8: Create Vue Component
  • Step 9: Initialize Vue Components
  • Step 10: Run Development Server

Step 1: Download Laravel Fresh App

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

Step 2: Add 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: Create Migration Files

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

Now open create_countries_states_table.php migration file from database>migrations and replace up() function with the following code:

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

Step 4: Create Models

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

Step 5: NPM Configuration

Install all Vue dependencies:


To calling Laravel API routes. You need to install vue-axios. So use run the following command on command prompt:


After installing all dependencies run this command:

Step 6: Add Routes

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

 

Step 7: Create Controller By Command

Now, lets create a controller named CountryStateController using command given below –

After that, go to app\Http\Controllers and open CountryStateController.php file. Then update the following code into your CountryStateController.php file:

Step 8: Create Vue Component

Next step, go to resources/assets/js/components folder and create a filed called DropdownComponent.vue. And update the following code into your DropdownComponent.vue. components file:

Now open resources/assets/js/app.js and include the FileUpload.vue component like this:app.js

Step 9: Initialize Vue Components

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 10: Run Development Server

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

Laravel 7 Restrict IP Address From Accessing Website

In this Laravel 7 Restrict IP Address From Accessing Website tutorial, I’ll show you how to restrict an IP address from accessing the website in laravel. In this tutorial you will learn to restrict user to access website using  IP Address in laravel. With this you will be able to restrict user with specified IP address from accessing the website, In this step by step tutorial we will be creating a middleware to restrict user with IP Address in laravel.

Laravel 7 Restrict IP Address From Accessing Website

  • Download Laravel Setup
  • Configure .env file
  • Create a Middleware
  • Register the Middleware

Step 1: Download Laravel Setup

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

Step 2: Configure .env file

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: Create a Middleware

Next step, Run the following artisan command to create a middleware named class BlockIpMiddleware:

Now, Go to app/Http/Middleware folder and open BlockIpMiddleware.php file. Then put the following code in BlockIpMiddleware.php file:

Step 4: Register the Middleware

Now, we need to register the middleware, so go to app/Http/ and open Kernel.php file. And register middleware as follow:

Laravel 7 Vue JS Flash Message Example

In this Laravel 7 Vue JS Flash Message Example Tutorial I’ll show you how to create Flash Message with Vue Js in laravel. In this tutorial you will learn to add Flash Message with Vue Js in laravel.

Laravel 7 Vue JS Flash Message Example

  • Step 1: Download Laravel Fresh App
  • Step 2: Add Database Detail
  • Step 3: Create Model And Migration
  • Step 4: NPM Configuration
  • Step 5: Add Routes
  • Step 6: Create Controller By Command
  • Step 7: Create Vue Component
  • Step 8: Register Vue App
  • Step 9: Run Development Server

Step 1: Download Laravel Fresh App

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

Step 2: Add 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: Create Model And Migration

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

This command will create one model name post.php and also create one migration file for the posts table. Now open create_postss_table.php migration file from database>migrations and replace up() function with following code:

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

Step 4: NPM Configuration

Install all Vue dependencies:

Step 5: Add Routes

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

Step 6: Create Controller By Command

Now, lets create a controller named PostController using command given below –

After that, go to app\Http\Controllers and open PostController.php file. Then update the following code into your PostController.php file:

Step 7: Create Vue Component

Next step, go to resources/assets/js/components folder and create a file called Post.vue.

And update the following code into your Post.vue components file:

Next, create a new components named flash.vue and update the following code into flash.vue file:

Now open resources/assets/js/app.js and include the Post.vue and Flash.vue component as follow:

Step 8: Register Vue App

Now, you need to create a blade view file to define Vue’s app. Go to resources/views folder and make a file named post.blade.php. Then update the below code into post.blade.php file:

Step 9: Run Development Server

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

Laravel 7 Vue JS Like Dislike Example

In this Laravel 7 Vue JS Like Dislike Example Tutorial I’ll show you how to implement Like Dislike with Vue Js in laravel. In this tutorial you will learn to create Like Dislike with Vue Js in laravel.

Laravel 7 Vue JS Like Dislike Example

  • Step 1: Download Laravel Fresh App
  • Step 2: Add Database Detail
  • Step 3: Run Make auth Command
  • Step 4: Create Model And Migration
  • Step 5: NPM Configuration
  • Step 6: Add Routes
  • Step 7: Create Controller By Command
  • Step 8: Create Vue Component
  • Step 9: Create Blade Views And Initialize Vue Components
  • Step 10: Run Development Server

Step 1: Download Laravel Fresh App

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

Step 2: Add 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: Run Make auth Command

Step 4: Create Model And Migration

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

This command will create one model name post.php and also create one migration file for the posts table. Now open create_postss_table.php migration file from database>migrations and replace up() function with following code:

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


Next, Navigate to app/Post.php and update the following code into your Post.php model as follow:

Next, Navigate to database/factories and open PostFactory.php. Then update the following code into it as follow:

and then run the following commad to generate fake data using faker as follow:

Step 5: NPM Configuration

Install all Vue dependencies:

Step 6: Add Routes

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

Step 7: Create Controller By Command

Now, lets create a controller named PostController using command given below –

After that, go to app\Http\Controllers and open PostController.php file. Then update the following code into your PostController.php file:

Step 8: Create Vue Component

Next step, go to resources/assets/js/components folder and create a files called LikeComponent.vue and DisLikeComponent.vue.

Now, update the following code into your LikeComponent.vue components file:

Next, update the following code into DisLikeComponent.vue file as follow:

Now open resources/assets/js/app.js and include the LikeComponent.vue and DisLikeComponent.vue component as follow:

Step 9: Create Blade Views And Initialize Vue Components

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:

Next, Navigate to resources/views/ and create one file name posts.blade.php. Then update the following code into your posts.blade.php file as follow:

Again, Navigate to resources/views/ and create one file name single-post.blade.php. Then update the following code into your single-post.blade.php file as follow:

Step 10: Run Development Server

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

Laravel 7 Vue JS Search Filter Example Tutorial

In this Laravel 7 Vue JS Search Filter Example Tutorial I’ll show you how to create search filter with Vue Js in laravel. In this tutorial you will learn to create search filter with Vue Js in laravel.

Laravel 7 Vue JS Search Filter Example Tutorial

  • Step 1: Download Laravel Fresh App
  • Step 2: Add Database Detail
  • Step 3: Run Make auth Command
  • Step 4: Create Model And Migration
  • Step 5: NPM Configuration
  • Step 6: Add Routes
  • Step 7: Create Controller By Command
  • Step 8: Create Vue Component
  • Step 9: Create Blade Views And Initialize Vue Components
  • Step 10: Run Development Server

Step 1: Download Laravel Fresh App

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

Step 2: Add 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: Run Make auth Command

Step 4: Create Model And Migration

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

This command will create one model name post.php and also create one migration file for the posts table.

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

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

Next, Navigate to app/Post.php and update the following code into your Post.php model as follow:

Next, Navigate to database/factories and open PostFactory.php. Then update the following code into it as follow:

and then run the following commad to generate fake data using faker as follow:

Step 5: NPM Configuration

Install all Vue dependencies:

Step 6: Add Routes

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

Step 7: Create Controller By Command

Now, lets create a controller named PostController using command given below –

After that, go to app\Http\Controllers and open PostController.php file. Then update the following code into your PostController.php file:

Step 8: Create Vue Component

Next step, go to resources/assets/js/components folder and create a file called FilterComponent.vue. Now, update the following code into your FilterComponent.vue components file:

Now open resources/assets/js/app.js and include the FilterComponent.vue component as follow:

Step 9: Create Blade Views And Initialize Vue Components

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:

Next, Navigate to resources/views/ and create one file name filter.blade.php. Then update the following code into your filter.blade.php file as follow:

Step 10: Run Development Server

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

Laravel 7 Summernote Example Tutorial

In this Laravel 7 Summernote Example Tutorial Tutorial I’ll show you how to use Summernote  in laravel. In this tutorial you will learn to use Summernote in laravel.

Laravel 7 Summernote Example Tutorial

  • Step 1: Install Laravel App
  • Step 2: Add Database Details
  • Step 3: Create Migration and Model File
  • Step 4: Add Routes
  • Step 5: Create Controler
  • Step 6: Create Blade File
  • Step 7: Run Development Server

Step 1: Install Laravel App

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

Step 2: Add Database Details

Step 3: Create Migration and Model File

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

Next, Navigate to database/migrations and open create_posts_table.php. Then update the following code into create_books_table.php file, as follow:

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

After that, Navigate to App directory and open Post.php model file. Then add the following code into Post.php model file, as follow:

app/Post.php

Step 4: Add Routes

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

Step 5: Create Controler

Now, lets create a controller named PostController using command given below –

Then, Navigate to app/http/controllers and open PostController.php file. And update the following code into your PostController.php file, as follow:

Step 6: Create Blade File

In this step, Navigate to resources/views folder. And create 2 blade views that named display.blade.php and create.blade.php the file inside this folder.

Then open create.blade.php file and update the following code into create.blade.php file, as follow:

Now open display.blade.php file and update the following code into your list.blade.php file, as follow:

Step 7: Run Development Server

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

Now, open the following URL in browser to see the output –

Laravel 7 Summernote Image Upload Example

In this Laravel 7 Summernote Image Upload Example tutorial, I’ll show you how to use Summernote for Image Upload in laravel. In this tutorial you will learn to upload image using Summernote in laravel.

Laravel 7 Summernote Image Upload Example

  • Step 1: Install Laravel App
  • Step 2: Add Database Details
  • Step 3: Create Migration and Model File
  • Step 4: Add Routes
  • Step 5: Create Controller
  • Step 6: Create Blade File
  • Step 7: Run Development Server

Step 1: Install Laravel App

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

Step 2: Add 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: Create Migration and Model File

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

Next, Navigate to database/migrations and open create_posts_table.php. Then update the following code into create_books_table.php file, as follow:

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

Now, go to App directory and open Post.php model file. Then add the following code into Post.php model file, as follow:

app/Post.php

Step 4: Add Routes

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

Step 5: Create Controller

Now, lets create a controller named PostController using command given below –

Then, Navigate to app/http/controllers and open PostController.php file. And update the following code into your PostController.php file, as follow:

Step 6: Create Blade File

In this step, Navigate to resources/views folder. And create a blade views that named create.blade.php the file inside this folder. Then open create.blade.php file and update the following code into create.blade.php file, as follow:

Step 7: Run Development Server

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

Now, open the following URL in browser to see the output –

Laravel 7 Vue JS Datatables Example Tutorial

In this Laravel 7 Vue JS Datatables Example Tutorial I’ll show you how to use Datatables with Vue Js in laravel. In this tutorial you will learn to use datatables with Vue Js in laravel.

Laravel 7 Vue JS Datatables Example Tutorial

  • Download Laravel Fresh App
  • Add Database Detail
  • Create Model And Migration
  • NPM Configuration
  • Add Routes
  • Create Controller By Command
  • Create Vue Component
  • Create Blade Views And Initialize Vue Components
  • Run Development Server

Step 1: Download Laravel Fresh App

Step 2: Add Database Details

Step 3: Create Model And Migration

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

This command will create one model name post.php and also create one migration file for the posts table. Now open create_posts_table.php migration file and put the following code in it:

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


Next, Navigate to app/Post.php and update the following code into your Post.php model as follow:

Next, Navigate to database/factories and open PostFactory.php. Then update the following code into it as follow:

now run the following command to generate fake data using faker as follow:

Step 4: NPM Configuration

You need to setup Vue and install Vue dependencies using NPM. So run the following command on command prompt:


Install all Vue dependencies:


Install vuejs-datatable:

Step 5: Add Routes

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

Step 6: Create Controller By Command

Now, lets create a controller named PostController using command given below –

After that, go to app\Http\Controllers and open PostController.php file. Then update the following code into your PostController.php file:

Step 7: Create Vue Component

Next step, go to resources/assets/js/components folder and create a file called DataTableComponent.vue.

Now, update the following code into your DataTableComponent.vue components file:

Now open resources/assets/js/app.js and include the DataTableComponent.vue component as follow:

Step 8: Create Blade Views And Initialize Vue Components

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:

Now, Navigate to resources/views/ and open welocome.blade.php. Then update the following code into your welcome.blade.php file as follow:

Step 9: Run Development Server