Category Archives: Laravel

Laravel Tutorials

Laravel 7/6 socialite Github Login Example

In this Login with Github in Laravel 7/6 example tutorial I’ll show you how to integrate Github login in laravel 7/6 using socialite package. Integrating Github login in Laravel 7/6 using socialite package is much easier. 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.

Laravel 7/6 socialite Github Login Example

In this step by step tutorial, you will learn to integrate Github login with your laravel 7/6 application. Please follow the steps give below:

  1. Install Laravel App
  2. Configure Database Detail
  3. Create Github App
  4. Add Github App Detail
  5. Install Socialite Package For Github Login
  6. Add Fillable Property in Model
  7. Add fields Into User Migration File
  8. Run Table Migration Command
  9. Create Auth Files By Artisan
  10. Add Routes
  11. Create Controller
  12. Add Github Auth Button On Laravel View
  13. Start Development Server
  14. Laravel 7, 6 Socialite GitHub Login App Looks Like

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: Configure Database Detail

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 Github App

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

Here you have to click New Auth APP button to Create your app. After this you need to register a new OAuth application page will open. So fill your app detail and submit it, Finally, you will see dashboard of your created github app. Now, copy your github app details.

Step 4: Add Github App Detail

In this step, add GitHub app details into service.php file. Go to config directory and open service.php file. Then add the client id and secret got from github app into service.php file:

Step 5: Add Fillable Property in Model

Now, go to app folder and open User.php Model file update fillable property like following:

app/User.php

Step 6: Add fields Into User Migration File

In this step, go to database/migrations directory and open create_users_table.php file. Then add following code into create_users_table.php file to add some fields into users table

Step 7: Run Table Migration Command

Now, Navigate to app/providers directory and inside this directory find AppServiceProvider.php file and open it in any text editor. Then add the following code in AppServiceProvider.php file:

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

Step 8: Install 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 9: Create Auth Files By Artisan

Install Laravel UI

Create Auth

NPM Install

Step 10: 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 11: Create Controller

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

After that, go to app/http/controllers directory and open GithubSocialController.php file. Then put the following code into GithubSocialController.php file:

Step 12: Add Github Auth Button On Laravel View

Now, go to resources/Views/Auth/ directory and open register.blade.php. After that, add the github login button into register.blade.php file:

So, navigate to resources/Views/Auth/ directory and open login.blade.php in any text editor. After that, add the github login button into login.blade.php file:

Step 13: 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 Eloquent Join Example Tutorial

In this Laravel 7 eloquent join example tutorial I will show you how many types of join and subquery join in laravel you will also learn to use laravel join with eloquent queries. In this tutorial you will learn about various joins in laravel eloquent model. In this article I’ll demonstrate the use of various types of laravel joins.In this step by step laravel join tutorial I will share example of laravel eloquent join (join, left join, right join, cross join, and advance join) and subquery join.

Laravel 7 Eloquent Join Example Tutorial

In this Laravel 7 Eloquent Join Example Tutorial we will learn about following laravel eloquent join query with examples:

  1. Laravel Join Eloquent
  2. Laravel Left Join / Right Join Eloquent
  3. Laravel Cross Join Eloquent
  4. Laravel Advanced Join Eloquent
  5. Sub-Query Joins

In laravel model when you want to fetch data from multiple table with associated relationship In that case you can fetch data using laravel joins. In laravel as per the need we have to use left join(), right join(), cross join() or to join two or multiple table.

1: Laravel Join Eloquent

In laravel if we join two tables it selects records if the given column values matching in both tables. It’s also known as laravel inner join eloquent.  Let’s say you have two tables, users and posts. Both have ID columns, and there is a user_id in the post, which is a foreign key for the users’ table.’

2: Laravel Left Join / Right Join Eloquent

Left Join Eloquent

Laravel left join query returns all rows from the left table, even if there is no matches in the right table. When you are using laravel left join eloquent with a query builder laravel left join fetch data from the left table. Even if there is no match in the right table.

Right Join Eloquent

Laravel right join query returns all rows from the right table, even if there is no matches in the left table. When you are using laravel right join eloquent with a query builder laravel right join fetch data from the right table. Even if there is no match in the left table.

3: Laravel Cross Join Eloquent

In laravel, the cross join selects every row from the first table with every row from the second table.

4: Laravel Advanced Join Eloquent

If in join query add some addition criteria with where clause it termed as advance join query.

5: Laravel Sub-Query Eloquent

In this laravel join example we are using join query in sub query.

 

Laravel 7/6 Instamojo Payment Gateway Integration Example

In this Laravel 7/6 Instamojo Payment Gateway Integration Example tutorial I will show you How to Integrate Instamojo Payment Gateway in Laravel 7/6. In this tutorial, we will learn how to integrate the instamojo payment gateway in the php laravel application via the instamojo PHP package.

In this step by step tutorial I will demonstrate you to integrate instamojo payment gateway in the laravel app without using curl APIs. We will simply install instamojo PHP package and integrate into our lastest laravel based application.

Instamojo Payment Gateway

Instamojo is one of the popular payment gateway, that allows us to accept payment from your customer. Instamojo is very simple, hassle free and easy to integrate payment gateway. Integrating Instamojo payment gateway in laravel 7 is a breeze. Instamojo processes refund payments, collect a payment, create payment are very easy and simple.

Laravel 7/6 Instamojo Payment Gateway Integration Example

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

  • Install Laravel Fresh Setup
  • Install Instamojo PHP package
  • Configuration .env file
  • Create Controller
  • Make Route
  • Create Blade View file
  • Start Development Server

Step 1: Install Laravel Fresh Project

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

Step 2: Install Instamojo PHP package

In this step, we will install Instamojo PHP package via the composer dependency manager. Use the following command to install Instamojo PHP package.

Step 3: Configuration in .env

Now, we will put following configuration detail in .env file:

Next, Go to the app/config/services.php and put the below code here.

Step 4: Create Controller

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

Go to app/Http/Controller/PayController and put the below code :

Step 5: 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

Step 6: Create Blade View file

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

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 –

Testing Card Credential

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: