Category Archives: Laravel

Laravel Tutorials

Use Join Query in Laravel 8 Eloquent to Boost Performance

In this Use Join Query in Laravel 8 Eloquent to Boost Performance tutorial I will show you how to use join query in laravel 8. In this tutorial you will learn about various 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 8 join tutorial I will share example of laravel eloquent join (join, left join, right join, cross join, and advance join) and subquery join.

Use Join Query in Laravel 8 Eloquent to Boost Performance

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

Inner Join Clause in Laravel

In laravel inner join if we join two tables it selects records if the given column values matching in both tables.

Cross Join Clause in Laravel

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

Laravel Left Join Clause Example

Laravel left join query returns all rows from the left table, even if there is no matches in the right table.

Laravel Right Join Clause Example

Laravel right join query returns all rows from the right table, even if there is no matches in the left table.

Laravel 8 Group By Example groupBy() Value in Laravel

In this Laravel 8 Group By Example tutorial I will show you how to use groupby function in laravel query. In this tutorial you will learn to use groupby function in laravel query. In this article I will share various example to use groupby function in laravel queries. In this example I will share groupby syntax and example in laravel queries.

Laravel groupBy()

The laravel groupBy() function is used for grouping the query results in Laravel. It allow us to group the data by specified criteria.

Example:-

Laravel 8 Eloquent whereBetween() Between Database Query Example

In this laravel whereBetween eloquent tutorial, I’ll show you how use whereBetween method in laravel queries. In this tutorial you will learn to use whereBetween function with laravel queries. You will also learn to use whereBetween in laravel query builder and laravel model. With whereBetween we can fetch data between provided range from table in laravel.

Laravel whereBetween

The laravel whereBetween clause is used to query data between provided range for specific column criteria. Suppose you want to know How many users have registered between two dates range. You can query this data using whereBetween eloquent methods.

Laravel whereBetween with provided range

In this example we will fetch the records with specified column value is in provided range.

Laravel whereBetween with start date and end date

In this example we will use Laravel whereBetween method to get records in between two provided dates.

How to SortBy Collection in Laravel 8

In this How to SortBy Collection in Laravel 8 tutorial I will show you how to sort laravel collection using laravel SortBy method. In this tutorial you will learn to use laravel sortby function to sort laravel collection. In this article I will share various example to use sortby method in laravel. In this example we will be using sortby() method to sort laravel collection by name, two fields, dates and relation.

Laravel SortBy() Method

The laravel SortBy() method is used to sorts the collection by given key.

How to SortBy Collection in Laravel 8

In this step by step tutorial I will demonstrate the use of laravel SortBy() method with example.

  • Collection Sort By Name
  • Collection Sort By Two Fields in Laravel
  • Collection Sort By Date in Laravel
  • Collection Sort By Count in Laravel
  • Collection Sort By Relation in Laravel

Laravel Collection Sort By Name Example

In this example we will be using SortBy() method to sort laravel collection by name.

Collection Sort By Two Fields in Laravel

In this example we will be using SortBy() method to sort laravel collection by two fields.

Collection Sort By Date in Laravel

In this example we will be using SortBy() method to sort laravel collection by date.

Collection Sort By Count in Laravel

In this example we will be using SortBy() method to sort laravel collection by count value.

Collection Sort By Relation in Laravel

In this example we will be using SortBy() method to sort laravel collection by relation.

Set Up Laravel Valet on Mac and Serve Sites with Laravel Valet

In this Set Up Laravel Valet on Mac and Serve Sites with Laravel Valet tutorial I will show you how to set up or configure a Laravel development environment on the Mac and how to run laravel web applications through Laravel Valet mechanism. In this tutorial you will learn to Set Up Laravel Valet on Mac and Serve Sites with Laravel Valet.

Set Up Laravel Valet on Mac and Serve Sites with Laravel Valet

In this step by step tutorial I will guide you through how to Set Up Laravel Valet on Mac and Serve Sites with Laravel Valet. Please follow the instruction given below:

Installing Homebrew in Mac

In this step we will install Homebrew package manager on your development machine.

Configure PHP in Mac

Since Laravel is a PHP framework, so we need to install the latest PHP version using Homebrew.

MySQL Installation

Now we will install MySql using following command.

Lets start the MySQL services using following command.


On MySQL startup the following message will be displayed on your terminal window:

Install Composer on MacOS

Now use the following command to install composer.


The hash file code for composer verfies the installer.


Next, we execute the composer-setup.php file; it helps in installing the Composer package in the existing directory.


Run the following command to configure the composer globally in our development system.


Verify Composer package manager installation.


Here is the similar output you will see on the terminal window.

Install Laravel Valet via Composer

Once installed, the following packages came along with it:


Run the following command to set the following folder with the path:


Now we need to install the Laravel Valet with given below command:

Create Laravel Application with Valet

Get inside the project root:


Run the laravel valet park command:


Create a new Laravel web application inside the same folder:


With the following URL you can check out the laravel application that we installed via Valet.

Laravel 8 Dynamic Google Charts Integration Tutorial with Example

In this Laravel 8 Dynamic Google Charts Integration Tutorial with Example I’ll will show how to integrate and use dynamic google charts in laravel 8 application. In this tutorial you will learn to integrate google charts in laravel 8 application. With Google Charts we can visualize data in your laravel web application. In this tutorial I’ll share example to demonstrate use of dynamic google charts in laravel.

Laravel 8 Dynamic Google Charts Integration Tutorial with Example

In this step by step tutorial I will demonstrate you how to create Dynamic Google Charts in laravel 8 application. Please follow the instruction given below:

Install Laravel Project

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

Switch into the project directory using following command.

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

Now we will add some dummy records in the database. Go to PHPMyAdmin  and run following sql query to add fake records.

Model and Migration

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


Open database/migrations/timestamp_create_wildlife_populations_table.php file and include the following code.

Add the following table properties in app/Models/WildlifePopulation.php file.

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

Setting Up 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

Generate and Configure Controller

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


Add the following code in app/Http/Controllers/ChartController.php file.

Show Google Line Chart in View

In this step we will create a blade view file. Create and open resources/view/home.blade.php file and put the following code in 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 8 Socialite Login with Facebook Tutorial with Example

In this Laravel 8 Socialite Login with Facebook Tutorial with Example tutorial I’ll show you how to implement login with facebook in laravel 8 using Socialite and Jetstream package. Integrating login with facebook in Laravel 8 using Socialite and Jetstream 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 8 Socialite Login with Facebook Tutorial with Example

In this step by step tutorial, you will learn to integrate Facebook login in your laravel 8 application using Socialite and Jetstream. Please follow the steps give below:

Install Laravel

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

Switch into the project directory using following command.

Add Database Details

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

Setting up Jetstream in Laravel

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

Run command to generate authentication templates such as login, register and email verification.


Next, run below command.


Run dev packages via node package manager.

Run command to migrate authentication properties.

Install Socialite Package in Laravel

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

Open config/app.php, register socialite plugin in providers, and aliases array.

Add Facebook ID in Users Table

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

Head over to newly created file migrations/timestamp_add_fb_id_column_in_users_table.php file, add the fb_id column value.

Also, add the Facebook ID table value in app/Models/User.php file.

Add Facebook App ID and Secret

After creating a Facebook app id and the secret app, register in the config/services file.

Generate and Configure Controller

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

Open app/Http/Controllers/SocialController.php and place the following code.

Setting Up Route

Open routes/web.php file and define the routes.

Add Login with Facebook Button in Login View

Next, add Login with Facebook button in Login view template, so add the following code in views/auth/login.blade.php file.

Start the application.


Test the progress on the following URL:

Laravel 8 Carbon Add Minutes Example

In this Laravel 8 Carbon Add Minutes Example tutorial I will show you how to add minute, minutes and sub minutes in Laravel. In this tutorial you will learn to add minutes with Laravel Carbon in Laravel application. In this example we will be using laravel carbon package add minutes on a current date. In this tutorial I will demonstrate you how to use addMinute(), addMinutes(), subMinutes() methods using Carbon date object.

Laravel 8 Carbon Add Minutes Example

In this tutorial I will share various example to add minute, minutes and sub minutes in Laravel using laravel carbon package.

Install Laravel

Start development server using following command.


Open the app on below link:


Thereafter, using below command generate a new controller for adding minute, minutes and sub minutes.

Laravel Carbon Add Minute using addMinute

addMinute():- The Laravel carbon addMinute() method is used to add minute.

Example:-

In this example we will add minute to carbon date using addMinute() method.

Laravel Carbon Add Minutes Using addMinutes

addMinutes():- The laravel carbon addMinutes() method is used to add minutes using Carbon.

Example:-

In this example we will add minutes to carbon date using addMinutes() method.

Laravel Carbon Add Sub Minutes Using subMinute

subMinute():- The laravel carbon subMinutes() method is used to add sub minutes using Carbon.

Example:-

In this example we will add sub minute to carbon date using subMinutes() method.

How to Add Hours with Laravel Carbon

In this laravel carbon add hour tutorial I will show you how to add hours using carbon package in laravel. In this tutorial you will learn add hour, hours and sub hours using laravel carbon addHour() and addHours() method. In this article I will share various example to add hour, hours and sub hour.

How to Add Hours with Laravel Carbon

In this tutorial I will share various example to add hour, hours and sub hour in Laravel using laravel carbon package.

Install Laravel

Get into the app:


Start the application:


Open the app to see the results on the browser:

Afterwards, you need a controller to add hour and sub hour in Laravel application:

Laravel Carbon Add Hour with addHour()

addHour():- The Laravel carbon addHour() method is used to add a hour.

Example:-

In this example we will add hour to carbon time using addHour() method.

Laravel Carbon Add Hours with addHours()

addHours():- The Laravel carbon addHours() method is used to add hours.

Example:-

In this example we will add hours to carbon time using addHours() method.

Laravel Carbon Add Sub Hour with subHour()

subHour():- The Laravel carbon subHour() method is used to add sub hour.

Example:-

In this example we will add sub hour to carbon date using subHour() method.

Laravel Carbon Add Sub Hours with subHours()

subHours():- The Laravel carbon subHours() method is used to add sub hours.

Example:-

In this example we will add sub hours to carbon time using subHours() method.

Laravel Carbon Add Years Tutorial with Example

In this Laravel 8 Carbon Add Years Example tutorial I will show you how to add year, years and sub years in Laravel. In this tutorial you will learn to add year with Laravel Carbon in Laravel application. In this example we will be using laravel carbon package to add year on a current date. In this tutorial I will demonstrate you how to use addYear(), addYears(), subYear() and subYears() methods using Carbon date object.

Laravel Carbon Add Years Tutorial with Example

In this tutorial I will share various example to add year, years and sub years in Laravel using laravel carbon package.

Setting up Laravel Project

Get into the project root:

Run the application:


To check the result use the following URL:


Next, create a new controller and add years and sub years in Laravel application:

Laravel Carbon Add Year with addYear()

addYear():- The Laravel carbon addYear() method is used to add Year to carbon date object.

Example:-

In this example we will add year to carbon date using addYear() method.

Laravel Carbon Add Years with addYears()

addYears():- The Laravel carbon addYears() method is used to add Years to carbon date object.

Example:-

In this example we will add years to carbon date using addYears() method.

Laravel Carbon Add Sub Year with subYear()

subYear():- The Laravel carbon subYear() method is used to add sub Year to carbon date object.

Example:-

In this example we will add sub year to carbon date using subYear() method.

Laravel Carbon Add Sub Years with subYears()

subYears():- The Laravel carbon subYears() method is used to add sub Years to carbon date object.

Example:-

In this example we will add sub years to carbon date using subYears() method.

Laravel Carbon Add Months Tutorial with Example

In this Laravel 8 Carbon Add months Example tutorial I will show you how to add month, months and sub months in Laravel. In this tutorial you will learn to add months with Laravel Carbon in Laravel application. In this example we will be using laravel carbon package add months on a current date. In this tutorial I will demonstrate you how to use addMonth(), addMonths(), subMonths() methods using Carbon date object.

Laravel Carbon Add Months Tutorial with Example

In this tutorial I will share various example to add month, months and sub months in Laravel using laravel carbon package.

Create Laravel Application

Get into the project root:

Start the laravel application:


Open below URL in browser:


Next, generate a brand new controller and add months and sub months in Laravel:

Laravel Carbon Add Month with addMonth()

addMonth():- The Laravel carbon addMonth() method is used to add month to carbon date object.

Example:-

In this example we will add month to carbon date using addMonth() method.

Laravel Carbon Add Months with addMonths()

addMonths():- The Laravel carbon addMonths() method is used to add months to carbon date object.

Example:-

In this example we will add months to carbon date using addMonths() method.

Laravel Carbon Add Sub Month with subMonth()

subMonth():- The Laravel carbon subMonth() method is used to add sub month to carbon date object.

Example:-

In this example we will add sub month to carbon date using subMonth() method.

Laravel Carbon Add Sub Months with subMonths()

subMonths():- The Laravel carbon subMonths() method is used to add sub months to carbon date object.

Example:-

In this example we will add sub months to carbon date using subMonths() method.

How to Change Date Format in Laravel App with Carbon

In this How to Change Date Format in Laravel with Carbon tutorial I will show you how to change the date format in laravel with carbon. In this tutorial you will learn to change date format with carbon date in laravel. In this article I will share various example to change date format using carbon date object in laravel. In this example I will show you how to change date format using carbon createFromFormat() and format() methods. The laravel carbon createFromFormat() method take two argument first give format of date and second one date and format() take one argument give format as you want.

Laravel Carbon createFromFormat() Methods

The laravel carbon createFromFormat() method take two argument first will specify the format of date and second one date object.

Laravel Carbon Format() Methods

The laravel carbon Format() method take one argument which specify the required format of date.

How to Change Date Format in Laravel App with Carbon

In this step by step tutorial I will demonstrate you with example on how to change date format using carbon method in laravel.

Setting Up Laravel App

Run the application:

Open below URL in browser:


Thereafter, you require to generate a new controller, there you will create the logic to change the date format:

Change Laravel Date Format Example