Category Archives: Blog

Blog

Laravel 7 Custom 404, 500 Error Page Example

In this Laravel 7 Custom 404, 500 Error Page Example tutorial I’ll show you how to create custom 404 and 500 error page in laravel. In this tutorial you will learn to create custom error page in laravel. In this step by step tutorial I’ll demonstrate the process to create custom 404 and 500 error page in laravel.

Laravel Create Custom Error Page

In this tutorial we will be creating custom error page for 404 and 500 erro. Please Follow the instruction given below to create custom 404, 500 error pages in laravel aps:

Create 404 View File
Create 500 View File
Modify Exceptions Handler

1: Create 404 View File

In this step we will be creating custom 404 error page. Lets go to resources/views directory and create a folder named errors. Then inside the errors folder, we will create a file called 404.blade.php.

resources/views/errors/404.blade.php

2: Create 500 View File

In this step we will be creating custom 500 error page. Lets Go to resources/views directory and create a folder named errors. Then inside the errors folder, we will create a file called 500.blade.php.

resources/views/errors/500.blade.php

3: Modify Exceptions Handler

Now, navigate to app/Exceptions and open Handler.php file and find the render() method. Then modify the render() method only as follow:

as well as render 500 error page in this file as follow:

How to Check User Online or Not in Laravel 7

In this How to Check User Online or Not in Laravel 7 I’ll show you how to check User Online or Not in Laravel 7 using custom middleware. In this tutorial you will learn to check user is online or not in laravel. In this step by step guide we will be creating a custom middleware to check User Online or Not.

How to Check User Online or Not in Laravel 7

  • Step 1: Install New Laravel App
  • Step 2: Add Database Detail
  • Step 3: Generate Auth Scaffolding
  • Step 4: Add Column in User Table
  • Step 5: Create a Middleware
  • Step 6: Register Middleware in Kernel
  • Step 7: Create Controller by Artisan
  • Step 8: Check Online Status in Blade File
  • Step 9: Run Development Server

Step 1: Install New 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

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: Generate Auth Scaffolding

In this step we will be generating laravel’s auth scaffolding using following command:

Step 4: Add Column in User Table

You need to add one column in the users table called last_seen. So, navigate database>migrations folder and open create_users_table file. Then update the last_seen column in this file as follow:

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

Step 5: Create a Middleware

In this step we will creating custom middleware using following command:

Next, navigate to app>Http>Middleware and open ActivityByUser.php middleware. Then update the following code into your middleware file:

Step 6: Register Middleware in Kernel

In this step, navigate app>Http and open Kernel.php. And register ActivityByUser.php middleware in the kernal.php file. You can see as follow:

Step 7: Create Controller by Artisan

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

Next, navigate to app>Http>Controllers and open UserController.php file. Then update the following method into your UserController.php file:

Open routes>web.php and create a route:web.php

Step 8: Check Online Status in Blade File

Navigate to resources>views and open home.blade.php. Then update the following code into home.blade.php.

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 Guzzle HTTP Client Requests Example

In this Laravel 7 Guzzle HTTP Client Requests Example tutorial I’ll show you how to implement or use Guzzle HTTP Client Requests in laravel. In this tutorial you will learn to use Guzzle HTTP Client Requests in laravel.

Laravel 7 Guzzle HTTP Client Requests Example

  1. Step 1: Install Laravel New App
  2. Step 2: Add Database Details
  3. Step 3: Install guzzlehttp/guzzle Package
  4. Step 4: Create Model and Migration
  5. Step 5: Add Routes
  6. Step 6: Create Controllers By Artisan
  7. Step 7: Run Development Server

Step 1: Install Laravel New 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: Install guzzlehttp/guzzle Package

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

Step 4: Create Modal and Migration

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

Navigate database/migrations/ and open create_posts_table.php file. Then update the following code into this file:

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

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 Controllers by Artisan

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

This command will create PostController and GuzzleController by the artisan command.

Next, Navigate to app/http/controller and open PostController.php.Then update the following methods into your controller file:

After that, Navigate to app/http/controller and open GuzzleController.php.Then update the following methods into your controller 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 –


Note that, you can also use guzzle http put and delete request in laravel apps as follow:

PUT REQUEST


DELETE REQUEST:

Laravel 7 Ajax Pagination Example Tutorial

In this Laravel 7 Ajax Pagination Example Tutorial I’ll show you how to implement ajax pagination in laravel. In this tutorial you will learn to create ajax pagination in laravel project.

Laravel 7 Ajax Pagination Example Tutorial

  1. Step 1: Install Laravel New App
  2. Step 2: Add Database Details
  3. Step 3: Create Model and Migration
  4. Step 4: Add Routes
  5. Step 5: Create Controllers By Artisan
  6. Step 6: Create Blade Views
  7. Step 7: Run Development Server

Step 1: Install Laravel New 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 Modal and Migration

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

Navigate database/migrations/ and open create_posts_table.php file. Then update the following code into this file:

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

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 Controllers by Artisan

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

This command will create PostController by the artisan command.

Next, Navigate to app/http/controller and open PostController.php.Then update the following methods into your controller file:

Step 6: Create Blade Views

In this step, we will create view/blade file. So navigate to resources/views folder and create the blade view as following:

Create first file name posts.blade.php and update the following code into it:

After that, create a new blade view file that named load_posts_data.blade.php and update the following code into it:

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 Sweet Alert Example Tutorial

In this Laravel 7 Sweet Alert Example Tutorial I’ll show you how to add Sweet Alert to laravel application. In this tutorial you will learn to add or implement Sweet Alert in laravel project.

Laravel 7 Sweet Alert Example Tutorial

  1. Create Methods in Controller
  2. Add Route
  3. Use SweetAlert on Blade Views File
  4. Run Development Server

Step 1: Create Methods in Controller

Step 2: Add Route

Navigate to routes/web.php and update the following routes:

Step 3: Use SweetAlert On Blade View File

Now, Navigate to resources/views folder and create one blade view file that named users.blade.php file and update the following code into users.blade.php file:

Note that, after creating a blade view file, you need to include sweet alert libary on your blade view files:

And you can call sweet alert methods as follow:

Step 4: 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 Install Vue JS Example Tutorial

In this Laravel 7 Install Vue JS Example Tutorial I’ll show you how to install Vue Js in laravel application. In this tutorial you will learn install Vue Js in laravel project.

Step 1: Download Laravel Fresh Setup

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

Step 2: Install Laravel UI Package

In this step we will install laravel UI package using following composer command:

Step 3: Adding Vue to Laravel App

In this step we will add Vue js to laravel application

Install Vue

This command will install vue into your laravel app.

Install Vue with auth

Step 4: Installing Vue.js Dependencies

Now, Install Vue.js dependencies following command:

Install NPM

Run NPM

Note that, You have already installed node and npm in your system for the above-given npm commands.

Laravel 7 Vue JS Post Axios Request Example

In this Laravel 7 Vue JS Axios post Request Example tutorial, I’ll show you how to implement post request with Vue JS Axios in laravel. In this tutorial you will learn to create post request with Vue JS Axios in laravel.

Laravel 7 Vue JS Post Axios Request Example

  • Step 1: Download Laravel Fresh Setup
  • Step 2: Setup Database Credentials
  • Step 3: Make Migration & Model
  • Step 4: Add Routes
  • Step 5: Make Controller By Command
  • Step 6: Install Vue Js dependency
  • Step 7: Create blade file and layout
  • Step 8: Run Development Server

Step 1: Download Laravel Fresh Setup

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

Step 2: Setup Database Credentials

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: Make Migration & Model

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

after that, open your posts migration file and paste the following code:


Again open your terminal and run the php artisan migrate to migrate our tables into your database:

After that, open Post model and update the following code into your app/Post.php model file:

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:  Make Controller By Command

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

This command will create a controller that name PostController inside the controller folder. Next, open it app/Https/Controller/PostController.php and update the following methods into your PostController file:

Step 6: Install Vue Js dependency

now open webpack.mix.js file and update the following code into your file. Make an asstes folder inside resources folder and copy js and sass folder inside it. Thats all. We need it to setup our laravel mix

Next Go to resources/assets/js/components/ folder. And create a new components name PostComponent.vue. Then update the following code into your PostComponent.vue file:

The above code is to send form data to controller using axios post request in laravel. Next, Go to resources/assets/js then open app.js file and intialize vue js components in this file. So open app.js file and update the following code into your app.js file:

Step 7: Create blade file and layout

Now, Open resources/layouts/app.blade.php and update the following code into it:

Next, resources/views/ and create a new blade view file name post.blade.php. And update the following code into your post.blade.php view file:

Step 8: 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 Axios Get Request Example

In this Laravel 7 Vue JS Axios Get Request Example tutorial, I’ll show you how to implement get request with Vue JS Axios in laravel. In this tutorial you will learn to create get request with Vue JS Axios in laravel.

Laravel 7 Vue JS Axios Get Request Example

  • Step 1: Download Laravel Fresh Setup
  • Step 2: Setup Database Credentials
  • Step 3: Generate Fake Data
  • Step 4: Add Routes
  • Step 5: Make Controller By Command
  • Step 6: Install Vue Js dependency
  • Step 7: Create blade file and layout
  • Step 8: Run Development Server

Step 1: Download Laravel Fresh Setup

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

Step 2: Setup Database Credentials

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: Generate Fake data

Now, use the following artisan command to generate dummy data:

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:  Make Controller By Command

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

Next, open it app/Https/Controller/UserController.php and update the following methods into your UserController file:

Step 6: Install Vue Js dependency

Next Go to resources/assets/js/components/ folder. And create a new components name UserComponent.vue. Then update the following code into your UserComponent.vue file:

The above code is to display users list using axios get request in laravel. Next, Go to resources/assets/js then open app.js file and intialize vue js components in this file. So open app.js file and update the following code into your app.js file:

Step 7: Create blade file and layout

Now, Open resources/layouts/app.blade.php and update the following code into it:

Next, resources/views/ and create a new blade view file name users.blade.php. And update the following code into your users.blade.php view file:

Step 8: 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 Infinite Scroll Example Tutorial

In this Laravel 7 Vue JS Infinite Scroll Example Tutorial I’ll show you how to create Infinite Scroll with Vue Js in laravel. In this tutorial you learn to create or implement Infinite Scroll with Vue Js in laravel application.

Step 1: Download Laravel Fresh Setup

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

Step 2: Setup Database Credentials

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:

This command will create post model, migration, and factory file into your project. Now, Go to app/database/migrations and find posts migration file. Then open it and update the following code into your posts migration file:

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

Step 4: Generate Dummy Data

Next step, generate fake or dummy data for posts table. So go to database/factories folder and find PostFactory.php file. After that, open and update the following code in PostFactory.php file as follow:

Next open terminal and run following command to generate dummy data for posts table:

Step 5: Add Route

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 –

This command will create PostController inside app/Http/Controllers/ folder. Now, open your PostController and update the following methods into your PostController File:

Step 7:  Configuration Vue JS

Install npm:


Install vue-resource:


Install vue-infinite-loading:

Step 8: Update app.js And Default Components

Go to resources/assets/js/ folder and find the app.js file inside this directory. Then update the following code into your app.js file:

resources/assets/js/app.js

resources/assets/js/components/ExampleComponent.vue

Step 9:  Add Vue Components on welcome.blade.php file

Go to resources/views and find welcome.blade.php file inside this folder. Then update the following code into your welcome.blade.php file:

And also update the following code into app.blade.php file, which is located on resources/views/layouts/ folder.

Step 10: Run Development Server

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

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 –