Category Archives: Blog

Blog

Laravel 7/6 Send Error Exceptions on Mail/Email

In this Laravel 7/6 Send Error Exceptions on Mail/Email tutorial I will show you how to send error exceptions on email in laravel. In this tutorial you will learn to send error exceptions on email in laravel. Here you will learn to send error exceptions on developer mail or as you want any other mail. In laravel most of error exceptions came for your laravel app. The app will be down and the user will leave your application. In Laravel, all exceptions are handled by the App\Exceptions\Handler class. This class contains two methods: report and render.

Laravel 7/6 Send Error Exceptions on Mail/Email

In Laravel, all exceptions are handled by the 

Laravel sends an error exception to mail steps

We are going to show you how you can send error exception mail in your laravel app. Just follow the few steps and it has finished.

  • Create Mail Class
  • Create an Email View
  • Send Error Exception Mail

Create Mail Class

This will create a class ExceptionMail in the app/Maildirectory.

Create Email View

Now, we have to create new view file inside the emails folder that file name email_exception.blade.php. and put the following code in and add your email_exception.blade.php file:

Send Error Exception Mail

Now, go to App\Exceptions\Handler file and put the following code in it:


Now, any error exception is thrown by your application. You will notified via an email with full error exception detail.

Laravel 7/6 Razorpay Payment Gateway Integration Tutorial

In this Laravel 7/6 Razorpay Payment Gateway Integration Example tutorial, I’ll show you how to integrate Razorpay payment gateway in laravel 7/6. In this tutorial you will learn to integrate Razorpay in laravel 7/6. In this step by step tutorial I’ll share laravel 7/6 Razorpay integration example.

Razorpay Payment Gateway

Razorpay is one of the popular payment gateway, that allows us to accept payment from your customer. Razorpay is very simple, hassle free and easy to integrate payment gateway. Integrating Razorpay payment gateway in laravel 7/6 is a breeze.

Laravel 7/6 Razorpay Payment Gateway Integration Tutorial

In this tutorial, you will learn to integrate Razorpay payment gateway in your laravel 7/6 project. Follow this step by step tutorial to learn Razorpay payment gateway integration in laravel 7/6.

  • Install Laravel App
  • Setup Database
  • Model & Migration
  • Make Route
  • Create Controller & Methods
  • Create Blade View
  • Start 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: Setup 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: Model & Migration

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

The above command will create a model name Payment and also create a migration file for the Payment table. Now, go to database/migrations/Payments.php file and replace function, below here :

Before we run php artisan migrate command go to app/providers/AppServiceProvider.php and put the below code :

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

Step 4: Make Route

Now we will create following routes in the web.php file. Go to app/routes/web.php file and create following routes in it. The first route is to list products and second route is to store payments_id and user information provided by the razorpay payment gateway.

routes/web.php

Step 5: Create Controller

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

After successfully create controller go to app/controllers/RazorpayController.php and put the below code :

Step 6: Create Blade view

Now we will create some blade view file name razorpay.blade.php and where we will show product list. Go to resources/views & create razorpay.blade.php file.

Get Your secret key from razorpay payment gateway dashboard and put the key in script tag section,

 

Go to resources/views and Create a new blade view file name thankyou.blade.php. It is used for showing after payment success.

Step 7: Start 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/6 Twitter Login Example Using Socialite Package

In this Laravel 7/6 Twitter Login Example Using Socialite Package tutorial I’ll show you how to integrate socialite Twitter social login in laravel application. In this tutorial you will learn to integrate Twitter login in laravel. In this article we will integrate login  with Twitter in laravel application. This tutorial is step by step guide for you on how to integrate Twitter social login in laravel using socialite package.

As we all know that users are not much interested in filling up long registration form to register with any application. Allowing users to login with their social media accounts is quick and powerful way to get registered/verified users for your laravel application. Allowing users to login with their social media accounts makes registration/login process much easier, it also encourages more users to register for your application. In this step by step tutorial, you will learn to integrate Twitter login with your laravel application.

Laravel 7/6 Twitter Login Example Using Socialite Package

  • Step 1: Install Laravel Fresh App
  • Step 2: Setup Database
  • Step 3: Download Socialite Package
  • Step 4:Create Twitter App
  • Step 5: Add Code In Model and Migration
  • Step 6: Run Migration
  • Step 7: Add Routes for Twitter App
  • Step 8: Create Controller & Methods
  • Step 9: Create Auth File And Login Button
  • Step 10: Run Development Server

Step 1: Install Laravel Fresh App

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

Step 2: Setup 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: Download Socialite Package

In this step we will Install Socialite Package via Composer using following command:

After Installing ‘socialite’ package, we need to add service provider and alias in config/app.php file as following.

config/app.php

Step 4: Create Twitter App

In this step we will create Twitter App for Twitter social login. Use the link provided to create twitter app.

After successfully create an app in twitter and get credentials from twitter dashboard, Set client id and client secret config/service.php file :

config/service.php

Step 5: Add Code In Model and Migration

In this step, Go to app/User.php and set fillable property put the below code here :

Next step, Go to app/database/create_users_table.php and put the below code here :

Step 6: Run Migration

In this step, go to app/providers/AppServiceProvider.php and update the below code into it:

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

Step 7: Add Routes for Twitter App

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 8: Create Controller

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

Now, go to app/http/controllers directory and open TwitterSocialController.php file. And put the following code in TwitterSocialController.php file:

Step 9: Create Auth File And Login Button

Install Laravel UI

Create Auth

NPM Install

After that, open register.blade.php file and login.blade.php. And update the following code into it:

In Resources/Views/Auth/register.blade.php

Resources/Views/Auth/login.blade.php

Step 10: 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/6 Image Upload with Validation

In this Laravel 7/6 Image Upload with validation example, we will learn how to upload and save image in laravel 7/6. In this laravel simple image upload example, I’ll show you how to validate upload image into folder and then save it into database. In this tutorial before saving image into database we will validate image and then save it into directory using. Before uploading the image we will perform server side validation. After successfully image upload into the database and folder we will display success message on the screen.

Laravel 7/6 Image Upload with Validation

  • Install Laravel Fresh App
  • Setup Database Details
  • Generate Image Migration & Model
  • Create Image Upload Route
  • Create Image Controller
  • Create Image Upload and Preview Blade View
  • Start Development Server

1). Install Laravel Fresh App

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

2). Setup 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.

3). Generate Image Migration & Model

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

The above command will create a model name Image and also create a migration file for Image table. Now, go to database/migrations file and put the below here :


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

4). Create Image Upload 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

5). Create Image Upload Controller

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

Now, go to app/controllers/ImageController.php and put the below code :

6). Create Image Upload and Preview Blade view

Now we will create a blade view file. Go to app/resources/views and create one file name image.blade.php :


Put css on image.blade.php in head section

Put the script on image.blade.php after closing of body tag

7). Start 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/6 Multiple Image Upload with Preview

In this Laravel Multiple Image Upload with Preview, I’ll show you how to upload image along with preview before upload in laravel. In this laravel multiple image upload example, I’ll show you how to validate upload image into folder and then save it into database. In this tutorial before saving image into database we will show preview of the images and then save it into directory. Before uploading the image we will display preview of the image. After successfully image upload into the database and folder we will display success message on the screen.

Laravel 7/6 Multiple Image Upload with Preview

  • Install Laravel Fresh Setup
  • Setup Database Credentials
  • Create Route
  • Generate Controller By Command
  • Create the blade view
  • Start Development Server

1: Install Laravel Fresh Setup

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

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.

3: Create 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

4: Generate Controller by Command

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

This command will create a controller name ImageController. Now, go to app/HTTP/Controller/ImageController and update the below code here :

5: Create the blade view

Now, we would create some blade files, Go to app/resources/views/ and create one blade view file name image.blade.php and put the following code into your file:

image.blade.php

6: 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/6 Ajax Image Upload With Preview Example Tutorial

In this Laravel 7/6 Ajax Image Upload With Preview Example Tutorial, I’ll show you how to upload image along with preview before upload using ajax in laravel. In this laravel ajax image upload with preview example, I’ll show you how to upload image into folder and then save it into database using ajax. In this tutorial before saving image into database we will show preview of the image and then save it into directory. Before uploading the image we will display preview of the image. After successfully image upload into the database and folder we will display success message on the screen.

Laravel 7/6 Ajax Image Upload With Preview Example Tutorial

  • Install Laravel App
  • Setup Database
  • Create Image migration file and model
  • Add Route For Image
  • Create Controller & Methods
  • Create Blade View
  • Create Folder
  • Run Development Server

1). Install Laravel App

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

2). Setup 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.

3). Create Image migration file and model

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

The above command will create a model name Photo and also create a migration file for Photo table. After successfully run the command go to database/migrations file and modify function as following

Before you run php artisan migrate command go to app/providers/AppServiceProvider.php and add the below code into AppServiceProvider.php file:

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

4). Add Route For Image

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

5). Create Controller

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

After creating controller go to app/controllers/ImageController.php and put the following code in it:

6). Create Blade view

Now, we will create a blade file. Go to app/resources/views and create one file name image.blade.php :

7). Create Folder

Now, Go to public folder and create a folder name images

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/6 File Upload Validation Example Tutorial

In this Laravel file Upload with validation example, we will learn how to upload and save file in laravel. In this laravel file upload example, I’ll show you how to validate upload file into folder and then save it into database. In this tutorial before saving file into database we will validate file and then save it into directory. Before uploading the files we will perform server side validation. After successfully file upload into the database and folder we will display success message on the screen.

Laravel 7/6 File Upload Validation Example Tutorial

  • Install Laravel Fresh New Setup
  • Setup Database Credentials
  • Generate Migration & Model
  • Add Route
  • Create Controller & Methods
  • Create Blade View
  • Run Development Server

1). Install Laravel Fresh New Setup

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

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.

3). Generate Migration & Model

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

The above command will create a model name file and also create a migration file for the file table. After successfully run the command go to database/migrations file and put the following code in it:

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

4). 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

5). Create Controller

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

After successfully create controller go to app/controllers/FileController.php and put the below code :

6). Create Blade view

In this step we will create a blade view file. Go to app/resources/views and create one file name file.blade.php :

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/6 Authentication Example Tutorial

In this Laravel 7/6 Authentication Example Tutorial I will show you how to generate authentication scaffolding in laravel. In this tutorial you will learn to enable or generate  authentication in laravel 7/6 version. In the new version of laravel make: auth command is no longer exists. Now in this tutorial we will learn how you can easily generate auth scaffolding in Laravel.

Laravel UI

Laravel UI is a new package that extracts the UI files of a Laravel project. Use the following command to install the laravel/ui package via composer:

After installing laravel / UI package, we have to generate the UI code, including laravel authentication.


The laravel/ui package comes with views for VUE, React and Bootstrap. You are allowed to enable one of following front end framework for authentication module.


You can generate the auth scaffolding at the same time:

The ui:auth Command

In addition to the new UI command, the larva / UI package comes with another command to generate scaffolding:

If you run the ui: auth command, it will generate the organic root, HomeController, oral view, and app.blade.php layout files. If you want to generate only views use the below command:

Now you need to run the below command for installing dependencies:

Laravel 7/6 Link Storage Folder Example

In this Laravel 7/6 Link Storage Folder Example tutorial, I will show you how to link storage folder and access file from there in laravel. In this tutorial you will learn to link laravel storage folder and access files from storage folder.

Use the following command to link storage folder in laravel:

The above command creates a symbolic link from public/storage to storage/app/public for you. Now any file in /storage/app/public can be accessed via a link like:

Now you can access your files the same way you do a symlink:

Create Controller And Model Laravel 7/6 Using Command

In this Create Controller And Model Laravel 7/6 Using Command tutorial I will show you how to Create Controller And Model Using Command In laravel. In this tutorial you will learn to create or generate controller and model using command in laravel. In this article we will learn about laravel artisan command to create controller and model. In this article I will demonstrate you with example to create controller and model using laravel command.

Create Controller And Model Laravel 7/6 Using Command

In this step by step tutorial I will show you how to create or generate controller and model using command in laravel. Please follow the instructions given below:

Create model command

Below is example command to create laravel model. Please  Use the php artisan make model for creating a model using the command line (CLI) :

The above command will create a photo model with following code:

Create Controller command

Below is example command to create laravel controller. Please  Use the php artisan make controller for creating a controller using the command line (CLI) :

The above command will create a controller named photoController with following code:

Create a Resource Controller Command

Below is example command to create a resource controller. Please  Use the php artisan make controller with –resource option for creating a resource controller:

Below is default resource controller code generated with the above command. It has already created some methods like index, update, edit, destroy, etc. It looks like this:

Command For Create Model and Controller

Below is example command to create laravel model and controller together.

How to Add a Column or Columns To Existing Table In Laravel

In this How to Add a Column or Columns To Existing Table In Laravel tutorial, I will show you how to add a culumn or columns to existing table in laravel. In this tutorial you will learn add one or multiple columns to database table using migration in laravel. In this article I will show you different ways you can alter existing table schema using migrations in laravel.

How to Add a Column or Columns To Existing Table In Laravel

In this step by step guide I will demonstrate you how to add new columns or columns to an existing table using Laravel migration.

Laravel Migration:

  • Add a single Column an existing table
  • Add Multiple Columns in Existing Table
  • Available Column Types

Add a single Column an existing table

Below is the example command to add single column to existing table.

It will create an add_type_to_notes file in the migration folder. It should be like this-

Run Migration Command

Now, run the following command to migrate table schema,

Add Multiple Columns in Existing Table

Below is the example command to add multiple column to existing table.

The above command will create a migration file, so go to database/migration folder and open your file and add column according to you:


Finally, run the below-given command for adding columns in your database table:

Available Column Types

Laravel 7/6 Custom Login Registration Example Tutorial

In this Laravel 7/6 Custom Login Registration Example Tutorial I will show you how to create custom login and registration system in laravel. In this tutorial you will learn to create custom login and registration system in laravel. Though laravel comes with default authentication system we can also create custom login, registration and logout functionality. In the step by step custom authentication tutorial I will show you to create controller, routes, model, and blade views files for custom login, registration and logout functionality.

Laravel 7/6 Custom Login Registration Example Tutorial

  • Install Laravel Fresh New Setup
  • Setup Database Credentials
  • Make Route
  • Create Controller & Methods
  • Create Blade View
  • Run Development Server
  • Conclusion

1). Install Laravel Fresh New Setup

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

2). Setup 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.

Next,  we will migrate the table into the database using the below command :

3). Make 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

4). Create Controller

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

After successfully create controller go to app/controllers/AuthController.php and update the below code in your controller:

5). Create Blade view

Now, we will create three-blade view files as following:

login blade.php


registration blade.php

dashboard.blade.php

Next, we will create a  style.css file inside app/public folder and updates the below code in your file:

6). 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 –