Category Archives: Blog

Blog

Laravel 7/6 Send Notifications as Voice Call

In this Laravel 7/6 Send Notifications as Voice Call tutorial I will show you how to Send notification as voice call in Laravel. In this tutorial, you will learn send notification as Voice or Phone call in laravel. In this example we will be using  nexmo-voice-channel for the send voice notification. In this step by step guide I’ll demonstrate you how to send notification as voice call in Laravel.

Laravel 7/6 Send Notifications as Voice Call

1. Install notifcation package

In first step, we will install voice notification Package via the composer dependency manager. Use the following command to install voice notification Package.

2. Configure nexmo credentials in .env

After installing nexmo-voice-channel voice notification Package we will set require application id and private key as following in .env file:

Then add your call from number and voice to config/services.php under the nexmo key. You can review the available voices in the Nexmo documentation.

3. Create a Notification channel

Now, in this step we will create notification channel as following:

In the below is another example demonstrating the package’s markup types you can use to create a notification:

Laravel 7/6 Generate Unique Slug Example

In this Laravel 7/6 Generate Unique Slug Example I will show you how to generate unique slug for blog posts title in laravel application. In this tutorial you will learn to generate unique slug for post title. In this example I will demonstrate you to generate unique slug or seo friendly slug url for post title. We will be using cviebrock eloquent sluggable laravel package for generating seo friendly url in laravel.

Laravel 7/6 Generate Unique Slug Example

  • Install Laravel Fresh New Setup
  • Setup Database Credentials
  • Install Eloquent Sluggable Package
  • Generate Model and Migration
  • Create Resource Route & Controller
  • Create the blade view
  • Start 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 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. Install Eloquent Sluggable Package

In this step, we will install Eloquent Sluggable Package via the composer dependency manager. Use the following command to install Eloquent Sluggable Package.

After installing eloquent sluggable package, run the following command:

4. Generate Model and 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 Post and also create a migration file for the post table. Now put the following code in it:

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

If you found any query builder error in command prompt go to => app\Providers\AppServiceProvider.php and put the below code here :

And then run this below command :

Now, add the fillable property inside Post.php file as following:

5. Create Resource Route & Controller

In this step we will create a resource route and controller using following command:

now, we have to add the resource route. Go to routes/web.php put the below routes here :

Now, go to app/HTTP/Controller/PostController and put the below code here :

6. Create the blade view

Now we will create following blade files:

  • List.blade.php
  • Create.blade.php

List.blade.php

Create.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 Get Record Last Week, Month, 15 Days, Year

In this Laravel Get Record Last Week, Month, 15 Days, Year tutorial I will  show you how to fetch records for last 1, 3, 6, 12 months and get the last date, last week, last, month, last year data records in laravel. In this tutorial you will learn how to get the last 1, 3, 6, 12 months, the last date, last week, last, month, last year data records in laravel.

Laravel Get Record Last Week, Month, 15 Days, Year

Table Of Content

  • Laravel Get Last Day Records
  • Get Last Week Data in Laravel
  • Laravel Get Last Month Records
  • Get Last 15 Days & 30 Days Records in Laravel
  • Fetch Month Wise Last Year Data
  • Fetch Last Year Record

Laravel Get Last Day Records

If you want to fetch records for last day from database tables. Provided eloquent Query can be used to fetch records for last day.

The output of the above laravel eloquent query looks like:

Get Last Week Data in Laravel

If you want to fetch records for current date from last week. Provided eloquent Query can be used to fetch records for last week. You can use the laravel eloquent method whereBetween to get the last week records from the database table as follow:

The output of the above laravel eloquent query looks like:

Laravel Get Last Month records

If you want to fetch records for last month from database tables. Provided eloquent Query can be used to fetch records for last month.

This query uses laravel method whereMonth() and get().

The output of the above laravel Eloquent query look like

Get Last 15 Days & 30 Days Records in Laravel

If you want to fetch records for last 15 days or 30 Days from database tables. Provided eloquent Query can be used to fetch records for last 15 days or 30 days.

Laravel Get Last Year Record

If you want to fetch records for last year from database tables. Provided eloquent Query can be used to fetch records for last year.

This query users laravel method whereYear() and get() to fetch records from db.

The output of above laravel eloquent query looks like

Fetch Month Wise Last Year Data

If you want to fetch month wise records from database tables. Provided eloquent Query can be used to fetch month wise records. You can use the laravel db::raw(), whereYear() and groupBy() to get previous year data month wise from the database table as follow:

The output of the above laravel eloquent query looks like

Laravel Get Current Date, Week, Month Wise, YEAR Data

In this Laravel Get Current Date, Week, Month Wise, YEAR Data tutorial I will show you how to get current date, current week, current, month, current year data in laravel. In this tutorial you will learn to get current date, current week, current, month, current year data in laravel.

Laravel Get Current Date, Week, Month Wise, YEAR Data

Table Of Content

  • Current Date Record Laravel
  • Get Current Week Data in Laravel
  • To Get Current Month Data in Laravel
  • Laravel Get Month Wise Current Year Data
  • Get Day Wise Current Week Data Laravel
  • Laravel Get Data Year Wise

Current Date Record Laravel

If you want to fetch records for current date from database tables. Provided eloquent Query can be used to fetch records for current date.

The output of the above laravel eloquent query looks like:

Get Current Week Data in Laravel

If you want to fetch records for current week from database tables. Provided eloquent Query can be used to fetch records for current week.

This query uses laravel eloquent method whereBetween().

The output of the above laravel eloquent query looks like:

To Get Current Month Data in Laravel

If you want to fetch records for current month from database tables. Provided eloquent Query can be used to fetch records for current month.

This query users laravel method whereMonth, whereYear and get().

The output of the above laravel eloquent query looks like:

Laravel Get Month Wise Current Year Data

If you want to fetch month wise records from database tables. Provided eloquent Query can be used to fetch month wise records.

This query uses db::raw(), whereYear(), and groupBy() methods.

Output of the above laravel eloquent query is look like

Get Day Wise Current Week Data Laravel

If you want to fetch day wise records from database tables. Provided eloquent Query can be used to fetch day wise records.

The output of the above laravel eloquent query looks like:

Laravel Get Data Year Wise

If you want to fetch year wise records from database tables. Provided eloquent Query can be used to fetch year wise records.

The output of the above laravel eloquent query looks like:

Laravel 7/6 Highcharts Example Tutorial

In this Laravel 7/6 Highcharts Example Tutorial I will show you how to implement highchart in laravel application. In this tutorial you will learn to implement highchart in laravel. In this example 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 application.

Laravel 7/6 Highcharts Example Tutorial

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

2. Create Controller

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

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

app/Http/Controllers/ChartController.php

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

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 7/6 Pie Chart using Charts JS Example Tutorial

In this Laravel 7/6 Pie Chart using Charts JS Example Tutorial I will show you how to implement pie chart using a chart js in laravel. In this tutorial you will learn to implement pie chart using a chart js in laravel applications. In this example we will be using charts.js to implement pie chart in laravel application.

Laravel 7/6 Pie Chart using Charts JS Example Tutorial

1. Create a route

First 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

2. Create Controller

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

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

app/Http/Controllers/ChartController.php

3. Create Blade View File

Now, we will create a blade file. Go to the resources/views/chart-js.blade.php and put the following javascript and HTML code for displaying the pie chart using the chart js:

Below is the list of javascript libraries need to be included before implementing charts.


Or also don’t forget to add this javascript code. The chart js library also provides so many options for the chart js. You can change or modify according to your requirements.

Laravel Get Next and Previous Record and Url Tutorial

In this Laravel Get Next and Previous Record and Url Tutorial I will show you how to get the next or previous record or data with URL in laravel application. In this tutorial you will learn to get the next or previous record or data with URL in laravel application. Working with any blog application in laravel we have to show the next or previous URL on posts. At that time we need to get the next record from the database table and the previous record from the database table. In this step by step tutorial I’ll demonstrate you to get the next or previous record or data with URL in laravel.

Laravel Get Next and Previous Record and Url Tutorial

1. Get previous record or data

We can access the previous record as following:

This laravel eloquent query is users where() and orderBy() methods to fetch previous records like title, URL, slug, etc from the database table in laravel

2. Get Next record or data

We can access the next record as following:

This laravel query is uses where(), first() and orderBy() to fetch next records from DB table.

Note: – To access data obtained from $next or $ previous variable. You can use it like this:

You can display the next and previous posts url as following:

Laravel 7/6 Create Newsletter Example Tutorial

In this Laravel 7/6 Create Newsletter Example Tutorial I’ll show you how to implement newsletter functionality in laravel application. In this tutorial you will learn to create newsletter feature in your laravel application. In this example we will be using MailChimp for setting up newsletter functionality in laravel project.

Laravel 7/6 Create Newsletter Example Tutorial

  • Install Laravel Fresh New Setup
  • Setup Database Credentials
  • Install Newsletter Package
  • Sign Up in MailChimp Get MailChimp API Key And List Id
  • Set MailChimp API Key And List Id in .env file
  • Create Resource Route & Controller
  • Create the blade view
  • Start 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. Install Newsletter Package

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

The package will automatically register itself. Use following command to publish the config file to config/newsletter.php:

4. Sign Up in MailChimp Get MailChimp API Key And List Id

Now, we have to sign up in MailChimp from https://mailchimp.com/. If you already have Mailchimp account then login directly. After successfully sign up or sign we can get api key and list id from mailchimp

5. Set MailChimp API Key And List Id in .env file

In this step we will set Mailchimp API key and list id in .env file:

6. Create Resource Route & Controller

Now, we will create a resource route along with controller:

This command will create a controller name NewsletterController and also inside by default seven methods like index, store.Next, We need to add the resource route. Go to routes/web.php put the below routes here :

Next open controller, Go to app/HTTP/Controller/NewsletterController and put the below code here :

7. Create the blade view

In this step, we will create a blade file, Go to app/resources/views/ and create one blade view name newsletter.blade.php. After creating the blade file, put the given code into your newsletter.blade.php file:

newsletter.blade.php

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 Currency Exchange Rate Calculator

In this Laravel 7/6 Currency Exchange Rate Calculator tutorial I will show you how to create currency exchange rates calculator in laravel. In this tutorial you will learn to integrate or implement live currency exchange rates calculator in laravel. In this tutorial, we will learn how to create currency exchange rates calculator in laravel applications without using any package with examples.

Laravel 7/6 Currency Exchange Rate Calculator

  • Install Laravel Fresh New Setup
  • Signup and Get API KEY
  • Create Route & Controller
  • Create the blade view
  • Start Development Server

Step 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

Step 2 :- SignUp and Get API KEY

Now, go to the below link:

Now obtain API Key from here.

Step 3 :- Create Route & Controller

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

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

Now open controller, Go to app/HTTP/Controller/CurrencyController and put the below code here :

Step 4:- Create the blade view

In this step we will create a blade files, Go to app/resources/views/ and create one blade view name currency.blade.php. After successfully create the blade view file, update the below-given code into your currency.blade.php file:

currency.blade.php

Step 5 :- 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 Query Scope Example Tutorial

In this Laravel Query Scope Example Tutorial I will show you how to use query scopes in laravel eloquent model. In this tutorial you will learn to implement and use query scopes in laravel eloquent model. I will Also show you how to create and use dynamic query scope in laravel applications.

Laravel Query Scope Example Tutorial

In this step by step guide I will demonstrate you to create and use dynamic query scope in laravel applications.

Create Basic Scope in Model

Here we will first create a basic scope. Go to app/Post.php and create a scope here:

Use Basic Query Scope on Controller:

We can use basic query scope as following:

Create Dynamic Scope in Model

Now we are creating a dynamic query scope in laravel model as following:

Use Dynamic Scope Query On Controller

We can use dynamic scope in laravel as following:

Apply Scope to Relationship Laravel

Here, you will learn how to use query scopes with laravel relationship. Go to your App/Category.php and create a relationship between Categories and Posts Tables:

Go to your App/Post.php and create a relationship between Posts and Categories Tables:

Use query scope with relationship

Here we can use query scope with relationship as following:

Laravel 7 Google Autocomplete Address Example Tutorial

In this Laravel 7 Google Autocomplete Address Example Tutorial, I’ll show you how to integrate Address or location Autocomplete using Google Autocomplete in laravel 7. In this tutorial you will learn to implement google autocomplete in laravel 7.

Google Autocomplete

Google autocomplete widget is used to display suggestions for places, address and location as soon as the user starts typing in the given input box.

Laravel 7 Google Autocomplete Address Example Tutorial

In this laravel 7 google autocomplete tutorial I’ll demonstrate you step by step process to integrate google autocomplete in laravel 7 project. Pleasae follow the instructions given below:

  • Install Laravel Application
  • Get Api Key From Google
  • Create Route
  • Generate Controller by Command
  • Create Blade View
  • Run Development Server
  • Conclusion

Step 1: Install Laravel Application

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

Step 2: Get Api Key From Google

Now, we need to get Google API key to enable the communication between client and Google server. Now follow the instructions given below to get Google API Key:

  • Visit Google Cloud Platform.
  • Click on the project dropdown at the top to create the project.
  • Click APIs & Services > Credentials.
  • Now, click on Create Credentials > API key.
  • Copy google API and store in some text file.
  • Now we need to enable few services, so click on Credentials > “Enable APIs and Services”, additionally enable “Maps JavaScript API” and “Places API” services.

Step 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

Step 4: Generate Controller by Command

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

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

Step 5: Create Blade view

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

Add Autocomplete Script

Step 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 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 Ajax 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 –

The above command will create a controller name ImageController. Now, open controller app/HTTP/Controller/ImageController and put the following code in it:

5: Create the blade view

Now, we will create some blade views files, Go to app/resources/views/ and create a blade 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 –