Category Archives: Laravel

Laravel Tutorials

Laravel 7/6 Dropzone Multiple File Upload

In this Laravel 7/6 Dropzone Multiple File Upload tutorial, I will show you how to upload multiple image file using dropzone drag and drop in laravel. In this tutorial you will learn to implement drag and drop image upload using dropzone package in laravel. In this tutorial we learn to :-

  • Uploading multiple images with dropzone
  • Saving images with unique file names to database

Laravel 7/6 Dropzone Multiple File Upload

  • Install Laravel App
  • Setup Database Credentials in .env
  • Create Route
  • Generate a Controller & Model
  • Create a View File
  • 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 Credentials in .env

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 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 a Controller & Model

In this step we will generate a controller and model file using following artisan command:


The above command will generate a Image model, migration file for Image Table and also will create one controller name ImageController.php. Now, go to database/migrations directory and open create_images_table.php file and put the following code in create_images_table.php file:

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

Next, Navigate to app/http/controllers direcotry and open ImageController.php. Then update the following methods into your ImageController.php file:

Step 5: Create Blade view

In this step, we will create a blade file. So go to /resources/views folder and create one file name image.blade.php. Now, put the following code into your image.blade.php file:

In the above view blade file, we necessary to include dropzone js and CSS. Here we are going to use CDN js and CSS of dropzone in laravel.

Step 6: 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 –

How to Increment and Decrement Column Value in Laravel

In this How to Increment and Decrement Column Value in Laravel tutorial I will show you how to Increment and Decrement Column Value in Laravel. In this tutorial you will learn to Increment and Decrement Column Value in Laravel.

How to Increment and Decrement Column Value in Laravel

In larave framework we have increment() and decrement() method that allows to increment or decrement column values in laravel.

1: Increment a column value Laravel

In this example code you will learn to increment column value using laravel increment() method.

If you want to customize column increment value then you can pass the second argument in the increment() function like below:

2: Decrement a column value Laravel

In this example code you will learn to increment column value using laravel decrement() method.

If you want to customize column decrement value then you can pass the second argument in the decrement() function like below:

3: Increment Or Decrement Without Using Laravel Methods

In this example code you will learn to Increment Or Decrement Without Using Laravel Methods

Increment column value by

Decrement column value by

Laravel 7/6 Angular JS CRUD Example Tutorial

In this Laravel 7/6 Angular JS CRUD Example Tutorial I will show you how to create a simple AngularJS CRUD application with laravel. In this step by step tutorial, we will be creating a simple AngularJS SPA blog application with laravel. In this article, you will learn how to create fully functional CRUD (Create, Read, Update and Delete) REST API using laravel and integrate it with AngularJS Single Page Application.

Laravel 7/6 Angular JS CRUD Example Tutorial

You have to just follow this step by step angularJS crud application with laravel tutorial to create a fully functional angularjs crud application with laravel.

Laravel Angular JS CRUD Tutorial

Follow the below steps and create laravel angular web crud applications:

  • Install Fresh Laravel Setup
  • Setup Database Credentials in .env
  • Create REST API Controller
  • Create a Model
  • Define Route
  • AngularJS application structure
    • AngularJS app.js
    • Create Angular js controller
  • Create blade view
  • Start development server

1). Install Fresh Laravel Setup

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

2). Setup Database Credentials in .env

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 REST API Controller

Now we will create REST API controller using following artisan command:

Now go to app/controller/API/CustomerController.php and put the following code in controller file:

4). Create a Model

In this step we will create a model file using following command:

Next, go to app/customer.php and update the below code into your file:

5). Define Route

Now, we will define the api route in routes/api.php file. So go to routes/api.php and update the below route into your file:

routes/api.php

6). AngularJS application structure

Now we will follow the following directory structure:

app – contains all AngularJS related JavaScript files
app/controllers – contains all AngularJS controllers
css – contains all CSS files
js – contains all regular JavaScript files for our UI.

AngularJS app.js

We will first create app.js in /public/app directory, create a new file name app.js and put the following code in it:

Here,

var app = angular.module(‘customerRecords’, []) creates an AngularJS module and assigns the object to the variable app. All AngularJS files will be reference the variable app
.constant(‘API_URL’, ‘http://localhost:8000/api/v1/’); defines a constant variable with the API URL.

Create AngularJS controllers

Now, go to  /public/app/controllers folder and create a controller file customers.js. And put the following code in your customers.js file:

7). Create a blade view

Now go to /resources/views and create a new file name index.blade.php and update the below code into your file:


Next, go to routes/web.php file and change welcome to index, like this:

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