Category Archives: Blog

Blog

Laravel 9 Create Custom Helper Functions Example

In this Laravel 9 Create Custom Helper Functions Example tutorial I will show you how to create custom helper in laravel 9. In this tutorial you will learn to create custom helper file in laravel 9 application . With custom helper file you can define functions that you can reuse in your laravel 9 application.

What Is Laravel 9 Custom Helper

In laravel 9, custom helper file helps you to reduce the re-writing the same code again and again. With custom helper file you can define the custom helper functions that you can use anywhere in your laravel 9 project.

How to Create Custom Helper In Laravel 9

In this step by step tutorial I demonstrate you how to create custom helper file in laravel project. I will also show you how to define custom helper function and to call them in laravel application:

Create helpers.php File

In custom helper file you can define your own functions and call anywhere in your laravel  project. Go to App directory and create a new file helpers.php like this app/helpers.php.

 

Add custom helper File Path In composer.json File

In this step, we will add custom helper file path in composer.json file. Go to root directory and open composer.json file and put the following code into the file:

composer.json

Run Command for autoloading custom helper file

Now, go to command prompt and type the given command:

How to use custom helper function in laravel 9

Now, you will learn how to call or use custom helper function in laravel 9:

1 – How to call custom helper function in laravel blade

2 – How to call custom helper function in laravel controller

Laravel 9 Auto Load More Data on Page Scroll with jQuery AJAX

In this Laravel 9 Auto Load More Data on Page Scroll with jQuery AJAX tutorial I’ll show you how to implement infinity scroll or dynamix ajax auto load more pagination on page scroll in laravel 9 using ajax. In this tutorial you will learn to implement dynamic auto load more pagination in laravel using ajax in laravel 9. In this step by step guide I’ll share example of ajax auto load more or infinity scroll in laravel 9 application.

Laravel 9 Auto Load More Data on Page Scroll with jQuery AJAX

In this step by step tutorial I will demonstrate you with example to create dynamix ajax load more pagination on page scroll in laravel. Please follow the instruction given below:

  • Install Laravel 9
  • Connecting App to Database
  • Create One Model and Migration
  • Add Route
  • Create Controller by Command
  • Create Blade View
  • Run Development Server
  • Test This App

Install Laravel 9

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

Connecting App to 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.

Create Model and Migration

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

Now, go to app/database/migrations and open posts migration file and add following fields:


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

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

Create Controller by Command

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

Once the above command executed, it will create a controller file PostController.php in app/Http/Controllers/ directory. Open the PostController.php file and put the following code in it.

app/Http/Controllers/PostController.php

Create a blade view

In this step we will create blade view file. Lets create a blade file posts.blade.php. And put  the below HTML code into your posts.blade.php file:

The blade view file will list all your blog posts when you scroll the page down. Next, update the following script into your blade view file:

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 9 Google Line Chart Tutorial Example

In this Laravel 9 Google Line Chart Example Tutorial I’ll will show how to use google line  chart in laravel 9 application. In this tutorial you will learn to implement google line char in laravel 9 project. With Google Charts we can visualize data in your laravel web application. In this tutorialI’ll share example to demonstrate use of google line graph chart in laravel 9.

Laravel 9 Google Line Chart Tutorial Example

  • Install Laravel App
  • Add Database Details
  • Add Route
  • Create Controller
  • Create Blade File
  • Run Development Server

Install Laravel App

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

Add 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.

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

Create Controller

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

Now, go to app/http/controller folder and open GoogleLineController.php. And put the following code into your GoogleLineController.php file:

Create Blade File

In this step, we will go to /resources/views/ folder and create a blade file name google-line-chart.blade.php. And put the following code into your google-line-chart.blade.php file:

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 9 Google Bar Chart Tutorial Example

In this Laravel 9 Google Bar Chart Tutorial Example I’ll will show how to use google Bar chart in laravel 9 application. In this tutorial you will learn to implement google Bar char in laravel 9 project. With Google Charts we can visualize data in your laravel web application. In this tutorialI’ll share example to demonstrate use of google Bar chart in laravel 9.

Laravel 9 Google Bar Chart Tutorial Example

In this step by step tutorial I will demonstrate you how to create google Bar char in laravel 9 application. Please follow instruction given below:

  • Install Laravel 9
  • Add Database Details
  • Generate Migration & Model File
  • Add Route
  • Create Controller
  • Create Blade File
  • Run Development Server

Install Laravel App

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

Add Database Configuration

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.

Generate Migration & Model File

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

Now, go to app directory and open Order.php file. And put the following code into your Order.php file:


Now, go to database/migrations/ and open create_orders_table.php file and update the following code:


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

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

Create Controller

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

Then go to app/http/controller folder and open OrderController.php. And put the following code into your OrderController.php file:

Create Blade File

In this step we will create blade file. Go to /resources/views/ folder and create one blade view file name google-bar-chart.blade.php. And add the following code into your google-bar-chart.blade.php file:

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 9 Google Pie Chart Tutorial Example

In this Laravel 9 Google Pie Chart Tutorial Example I’ll will show how to use google Pie chart in laravel 9 application. In this tutorial you will learn to implement google Pie chart in laravel 9 application. With Google Charts we can visualize data in your laravel application. In this tutorialI’ll share example to demonstrate use of google Pie chart in laravel 9.

Laravel 9 Google Pie Chart Tutorial Example

  • Install Laravel 9
  • Add Database Details
  • Add Route
  • Create Controller
  • Create Blade File
  • Add Google Chart Library
  • Run Development Server

Install Laravel App

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

Add 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.

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

Create Controller

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

Then go to app/http/controller folder and open GooglePieController.php. And put the following code into your GooglePieController.php file:

Create Blade File

In this step, go to /resources/views/ folder and create a blade file name google-pie-chart.blade.php. And put the following code into your google-pie-chart.blade.php file:

Add Google Chart Library

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 9 Highcharts Example Tutorial

In this Laravel 9 Highcharts Example Tutorial I will show you how to implement highchart in laravel 9 application. You will learn to implement highchart in laravel 9. In this article I will demonstrate the use of highchart in laravel application. In this example we will fetch month wise data and display month wise data in highcharts for analytics on laravel 9 application.

Laravel 9 Highcharts Example Tutorial

In this step by step tutorial I will demonstrate you how to implement Highcharts in Laravel 9 application. Please follow the instruction given below.

Install Laravel 9

First of all we need to install a fresh laravel project. Download and install Laravel 9 using the below command

Setup Database

Now, create a MySQL database and connect it with your laravel application. After creating database we need to set database credential in application’s .env file.

Create web routes

In the first step we will define routes in “routes/web.php” file. Lets open “routes/web.php” file and add the following routes in it.

routes/web.php

Create Controller

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

Once the above command executed, it will create a controller file HighChartController.php in app/Http/Controllers/ directory. Open the HighChartController.php file and put the following code in it.

app/Http/Controllers/HighChartController.php

Create Blade File

Now, we will create a blade view file. Go to the resources/views/highchart.blade.php and put the below javascript and HTML code for displaying the highchart. So go to the resources/views/ and update the below javascript and HTML code for displaying the highchart:

Remember to include highchart js libraries on your blade file:


Use below javascript as per requirement :

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 9 Charts JS Chart Example Tutorial

In this Laravel 9 Charts JS Example Tutorial I will show you how to implement Charts JS in laravel 9 application. In this tutorial you will learn to implement Charts JS in laravel 9. In this example I will demonstrate the use of Charts JS in laravel application. In this example we will create pie chart using a chart js in laravel 9 application.

Laravel 9 Charts JS

ChartJS is easy to use and simple HTML5 based JavaScript charts library. With Chart js we can create animated, interactive graphs in our laravel 9 application.

Laravel 9 Charts JS Example Tutorial

In this step by step tutorial I will demonstrate you to fetch the last 7 days data and display it on pie chart using charts js in laravel. Please follow the instruction given below:

  • Install Laravel 9
  • Setup Database Credentials
  • Create a route
  • Create Controller
  • Create Blade View File and Integrate Chart js Library
  • Start Development Server

Install Laravel 9

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

Make sure you have composer installed.

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.

Create a route

In the first step we will define routes in “routes/web.php” file. Lets open “routes/web.php” file and add the following routes in it.

routes/web.php

Create Controller

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

Once the above command executed, it will create a controller file ChartJSController.php in app/Http/Controllers/ directory. Open the ChartJSController.php file and put the following code in it.

app/Http/Controllers/ChartJSController.php

Create Blade View File and Integrate Chart js Library

Now, we will create a blade view file. Go to the resources/views/chart-js.blade.php and put the below javascript and HTML code for displaying the chart. So go to the resources/views/ and update the below javascript and HTML code for displaying the chart using chart js library:

Remember to include highchart js libraries on your blade file:


Use below javascript as per requirement :

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 9 Create JSON File Download From Text

In this Laravel 9 Create JSON File and Download From Text tutorial I will show you how to convert form data to JSON and download json file. I will also show you how to convert and insert json format data into MySQL database. In this tutorial you will learn convert form data or text file data into json format and to save text file data from JSON data into MySQL database and download data from mysql database.

Laravel 9 Create JSON File & Download From Text

In this step by step tutorial I will guide you through how to save form or text data into database with json format and to download in laravel 9 application. Please follow the instruction given below:

  • Install Laravel 9
  • Setup Database
  • Generate migration and model
  • Migrate Database
  • Add Route
  • Create controller
  • Create blade view
  • Start Development Server

Install Laravel 9

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

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.

Migrate Database

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

Generate migration 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 and migration file. Go to app/database/migration and find the migration file name create_tests_table.php and update the following code into it:

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

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

Create Controller

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

Now, go to app/http/controllers open JsonController and create two method. The first method is to display the form and second method convert form data to json format and save it to database:

Create Blade view

In this step we will create blade view file. Now, create a blade view name json_form.blade.php in resources/views directory. Put the below code here :

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 9 Store JSON Format Data to Database

In this Laravel 9 Store JSON Format Data to Database tutorial I will show you how to store/insert json form data into mysql database. I will also show you how to convert and insert json format data into MySQL database. In this tutorial you will learn convert form data into json format and to save data from JSON data into MySQL database.

Laravel 9 Store JSON Format Data to Database

In this step by step tutorial you will learn how to store JSON format data into MySQL database in laravel 9 application. Please follow the instruction given below:

  • Install Laravel 9
  • Setup Database
  • Generate migration and model
  • Migrate Database
  • Add Route
  • Create controller
  • Create blade view
  • Start Development Server

Install Laravel 9

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

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.

Migrate Database

Run the migration to create database table using following artisan command:

Generate migration and model

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

Once above command is executed there will be a migration file created inside database/migrations/ directory, just open create_tests_table.php migration file and update the function up() method as following:

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

Add Route

In this step, we will create two routes in the web.php file. One to display form and the second route is to store data in JSON to MySQL database. Open app/routes/web.php file and put the following routes in it:

Create controller

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

Once the above command executed, it will create a controller file JsonController.php in app/Http/Controllers/ directory. Open the JsonController.php file and put the following code in it.

app/Http/Controllers/JsonController.php

Create blade view

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

json.blade.php

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 9 Get Current User Location From IP

In this Laravel 9 Get Current User Location From IP tutorial I will show you how to get user location information using user IP address in laravel 9. In this tutorial you will learn to get country name, country code, city name, and address from user IP address in laravel 9. When you working on web development project you come to situation where you may want to fetch user information such as country Name, country Code, region Code, region Name, city Name, zip Code, iso Code, postal Code, latitude, longitude, metro Code, metro Code from ip address in laravel 8. In this example I will help you to fetch user info from IP their ip address. We will be using stevebauman/location package in this example to fetch country name, country code, city name, and address from IP address.

How to Get Current User Location in Laravel 9

In this tutorial you will learn how to get current user location with ip address using stevebauman location package. The stevebauman/location laravel package is used to get users location data by their IP Address. This helps in retrieving user’s location information from IP address. The location library helps in retrieving following location information:

  • Country name and code
  • Region name and code
  • City name
  • Zipcode
  • ISO code
  • Postal code
  • Latitude and longitude
  • Metro code

Laravel 9 Get Current User Location From IP

  • Install Laravel 9
  • Connecting App to Database
  • Install stevebauman/location Package
  • Create Route
  • Create Controller By Artisan Command
  • Create Blade View
  • Run Development Server

Install Laravel 9

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

Connecting App to 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.

Install stevebauman/location Package

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

Then, Go to config directory and open app.php file. And register this package into laravel 8 app by adding the following code into your app.php file:

Create 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

Create Controller By Artisan Command

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

Now, go to app\Http\Controllers and open UserController.php file. Then put the following code into your UserController.php file:

Create Blade View

In this step we will create blade view file. Go to resources/views directory and create user.blade.php. Then add the following code into it:

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 9 Socialite Login with Linkedin Example

In this Laravel 9 Login with Linkedin Example Tutorial I’ll show you how to integrate socialite LinkedIn social login in laravel 9 application. In this tutorial you will learn to integrate LinkedIn login in laravel. In this article we will integrate login  with LinkedIn in laravel 9 application.

Laravel 9 Login with Linkedin

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 linkedin login with your laravel 9 application.

Laravel 9 Socialite Login with Linkedin Example

This tutorial is step by step guide for you on how to integrate linkedin social login in laravel 9 using socialite package.

Step 1:- create linkedin app by click the following url :- https://www.linkedin.com/developers/apps/new . And create linkedin app.

Step 2:- After successfully create the app set the redirect URL for example :

Step 3:- Finally, you redirect to dashboard by linkedin.com. So you can copy client id and secret from linkedin app dashboard.

  • Install Laravel 9
  • Connecting App to Database
  • Configure the Linkedin App
  • Install Socialite & Configure
  • Add Field In Table Using Migration
  • Install Jetstream Auth
  • Make Routes
  • Create Linkedin Login Controller By Command
  • Integrate Linkedin Login Button In Login Page
  • Start Development Server

Install Laravel 9

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

Connecting App to 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.

Configure Linkedin App

In this step, we will create linkedin app for client and secret key, go to following link

Now create linkedin app filling the details and create your linkedin app. After creating the app set the redirect URL. Now, copy the client id and secret from linkedin app dashboard.Now, configure Linkedin app with this laravel app. So, open your laravel Linkedin social login project in any text editor. Then navigate the config directory and open service.php file and add the client id, secret and callback url:

Install Socialite & Configure

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

Then add the Facade in config/app.php:

Add Field In Table Using Migration

Now, we will create a migration file to add social login fields using following command:

Now, open the add_social_login_field.php file, which is found inside database/migration directory and add the following code into it:


After successfully add field in database table. Then add fillable property in User.php model, which is found inside app/Models/ directory:


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

Install Jetstream Auth

In this step, install jetstream laravel auth scaffolding package with livewire. We have provided a complete guide in this Laravel 9 Auth Scaffolding using Jetstream Tutorial.

Make 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

Create Linkedin Login Controller By Command

In this step, run the following command to create LinkedinSocialiteController.php file:

Now, go to app/http/controllers directory and open LinkedinSocialiteController.php file in any text editor. Then add the following code into LinkedinSocialiteController.php file:

Integrate Linkedin Login Button In Login Page

In this step, integrate linkedin login button into login.blade.php file. So, open login.blade.php, which is found inside resources/views/auth/ directory:

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 9 Socialite Login with Github Example Tutorial

In this Laravel 9 Socialite Login with Github Example Tutorial I’ll show you how to integrate Github login in laravel 9 using socialite package. Integrating Github login in Laravel 9 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 9 Socialite Login with Github Example Tutorial

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

  • Install Laravel 9
  • Configure Database With App
  • Configure Github App
  • Install Socialite & Configure
  • Add Field In Table Using Migration
  • Install Jetstream Auth
  • Make Routes
  • Create Controller By Command
  • Implement Github Login In Login Page
  • Start Development Server

Install Laravel 9

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

Configure Database With App

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.

Configure 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.

Now, 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:

Install Socialite & Configure

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

Add Field In Table Using Migration

In this step we will create migration to add some fields using following command:

After that, open the add_social_login_field.php file, which is found inside database/migration directory and add the following code into it:


After successfully add field in database table. Then add fillable property in User.php model, which is found inside app/Models/ directory:


Now, run following command to migrate database schema.

Install Jetstream Auth

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

Now, you have to install livewire with jetstream. Use the following command to install livewire with jetstream in laravel application:

Install necessary NPM dependency:

Start node development server:

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

Make Routes

In this step, Go to routes directory and open web.php file. Then add the following routes into web.php file:

Create Controller By Command

In this step, run the following command to create GithubSocialController.php file:

Now, go to app/http/controllers directory and open SocialGithubController.php file in any text editor. Then put the following code into SocialGithubController.php file:

Implement Github Login In Login Page

In this step, implement github login button into login.blade.php file. So, open login.blade.php, which is found inside resources/views/auth/ directory:

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 –