Category Archives: Blog

Blog

Laravel 7/6 Multiple File Upload With Validation Example

In this Laravel multiple file Upload with validation example, we will learn how to upload and save multiple file in laravel. In this laravel multiple file upload example, I’ll show you how to validate upload multiple file into folder and then save it into database. In this tutorial before saving file into database we will validate file and then save it into directory. Before uploading the files we will perform server side validation. After successfully file upload into the database and folder we will display success message on the screen.

Laravel 7/6 Multiple File Upload With Validation Example

  • Download Laravel Fresh New Setup
  • Setup Database Credentials
  • Generate Migration & Model
  • Make Route
  • Create Controller & Methods
  • Create Blade View
  • Run Development Server

1). Download Laravel Fresh New Setup

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

2). Setup Database Credentials

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

3). Generate Migration & Model

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

The above command will create a model name file and also create a migration file for the file table. After successfully run the command go to database/migrations file and put the below here :


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

4). Add Route

After this, we need to define routes in “routes/web.php” file. Lets open “routes/web.php” file and add the following routes in it.

routes/web.php

5). Create Controller

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

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

6). Create Blade view

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

7). Run Development Server

Now we are ready to run our example so lets start the development server using following artisan command –

Now, open the following URL in browser to see the output –

Laravel 7/6 Stripe Payment Gateway Integration Example

In this Laravel 7/6 stripe payment gateway integration tutorial, I’ll show you how to integrate stripe payment gateway in laravel 7. In this tutorial you will learn to integrate stripe in laravel 7. In this step by step tutorial I’ll share laravel 7 stripe integration example.

Stripe Payment Gateway

Stripe is one of the most popular payment gateway, that allows us to accept payment worldwide. Stripe is very simple, hassle free and easy to integrate payment gateway. Integrating stripe payment gateway with laravel is a breeze. After integrating stripe in laravel you will be able to collect payment via simple payment form which allow customer to provide card information like card number, expiry date and a CVC code.

Laravel 7/6 Stripe Payment Gateway Integration Example

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

Laravel 7/6 Stripe Payment Gateway Integration Example

  • Step 1: Install Laravel Fresh Setup
  • Step 2: Install stripe Package
  • Step 3: Set Secret Credential
  • Step 4: Make Route
  • Step 5: Create Controller
  • Step 6: Create Blade View file
  • Step 7: Run Development Server

Step 1: Install Laravel Fresh Project

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

Step 2: Install Stripe package

Now, we need to install stripe-laravel package in our project. Open your terminal and switch to project directory and use the following composer command to install stripe-laravel package.

After that, we need to register the provider and aliases. Go to the app/config/app.php and put the below lines here :

Step 3: Set Secret Credential

Now, we need to set stripe key and secret key in our project’s .env file. In stripe dashboard switch to the test mode and get the stripe key and secret. Now, open .env file located in project’s root folder and set the stripe key and secret as following –

.env file

You will also need to set up the Stripe API key, Let’s open or create the config/services.php file, and add or update the 'stripe' array as following:

Step 4: Make Route

After this, we need to add following two routes in “routes/web.php” to display barcode. Lets open “routes/web.php” file and add following route.

routes/web.php

Step 5: Create Controller

Now, lets create a payment controller using following command

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

Step 6: Create Blade View file

In this step, we will create view/blade file to accept stripe payment. Lets create astripe.blade.php” file in “resources/views/” directory and put the following code in it.

resources/views/stripe.blade.php

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

Testing Card Credential

Laravel Get Current URL With Parameters

In this get the current URL with parameters tutorial I will show you how to get the current URL , parameters, domain etc details from current url in laravel. In this tutorial you will learn how can you get the current URL with parameters, previous URL, global URL, current URL Path in laravel.

Laravel Get Current URL With Parameters

How to Get Current Request URL

In the following example we have fetched the current url:

Use global url function

In the following example we have fetched the current url using global url function.

In the following example we have fetched the current url using current function.

In the following example we have fetched the current url using current full URL with query string parameters

How to get Current URL path

In the following example we have fetched the current url path.

Get the previous URL in Laravel

In the following example we have fetched the previous url.

Laravel Check Old Password and Updating a New Password

In this Laravel Check Old Password and Updating a New Password tutorial I will show you how to check old password and update with new password in laravel. In this tutorial you will learn to check old password and update new password in laravel. In this article I will demonstrate you how can you easily update the new password with old password validation.

Laravel change password old password validation

In this example we have a function to change user password checking old password. In the below function we have to pass old password, new password and confirm password.

Example:-

Laravel 7 FullCalendar Ajax Example Tutorial

In this Laravel fullcalendar example tutorial I’ll show you how to display events on the calendar using fullcalendar components in laravel apps. In this tutorial you will learn to display events on the calendar using fullcalendar in laravel. This tutorial you will also learn to show dynamic event data on calendar using  fullcalendar components in laravel.

Laravel 7 FullCalendar Ajax Example Tutorial

  • Install Laravel App
  • Setup Database
  • Generate Migration & Model
  • Make Route
  • Create Controller & Methods
  • Create Blade View
  • Run Development Server

1). Install Laravel App

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

2). Setup Database

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

3). Generate Migration & Model

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

The above command will create a model name Event and also create a migration file for the Events table.Now go to database/migrations folder and open create_events_table.php file. Then put the following code into create_events_table.php file, as follow:

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

4). Make Route

After this, we need to define routes in “routes/web.php” file. Lets open “routes/web.php” file and add the following routes in it.

routes/web.php

5). Create Controller

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

After successfully create controller go to app/controllers/FullCalendarController.php and update the below code :

6). Create Blade view

In this step we will create a blade file. Go to app/resources/views and create one file name fullcalendar.blade.php

Put the script on fullcalendar.blade.php, after the closing of the body tag

7). Run Development Server

Now we are ready to run our example so lets start the development server using following artisan command –

Now, open the following URL in browser to see the output –

Laravel 7/6 Flash Message Example

In this Laravel Flash Message Example tutorial I will show you how to create or implement flash message in laravel application. In this tutorial you will learn to implement flash message in laravel. While working with laravel application we come to situations where we want to show/display various flash success and error messages. In this example we will be using sweet alert js to display various type of flash messages or notifications.

Laravel 7/6 Flash Message Example

In this step by step guide I will demonstrate you how you can implement success or error messages with sweet alert js in your laravel application.

Laravel Flash Message

In this tutorial we will learn to following types of flash messages

  • Laravel Success Flash Message
  • Laravel Error Flash Message
  • Laravel Flash Success With Sweet alert
  • Laravel Flash Error With Sweet alert

Laravel Success Flash Message

Below is example to display success message:

Below is example to send and display success message on redirect method:

Laravel Error Flash Message

Below is example to display error message:

Below is example to send and display error message on redirect method:

Laravel Flash Success With Sweet Alert

If you want to show a success message with sweet alert, use the following code in your blade files:

Laravel Flash Error With Sweet Alert

If you want to show an error message with a sweet alert use the following code in your blade files:

How to Create Custom Helper In Laravel

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

What Laravel Custom Helper

In laravel, 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 project.

How to Create Custom Helper In Laravel

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 File Path In composer.json File

In this step, we will add 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

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

Now you can use your custom helper functions by calling this functions remove_special_char(), random_code() etc.

Now, I’ll show you how to use custom helper function in your laravel project:

Example 1

Example 2

How to Generate sitemap.xml file in Laravel

In this How to Generate sitemap.xml file in Laravel tutorial I will show you how to create sitemap.xml file in laravel application. In this tutorial you will learn to create sitemap.xml file for you laravel website. Sitemap.xml file is important for any website, it is used by search engines for indexing the website. In this step by step guide I will demonstrate you how to create search engine or seo friendly sitemap.xml for laravel websites.

How to Generate sitemap.xml file in Laravel

In this tutorial you will learn to create search engine friendly sitemap.xml in laravel. Here I will demonstrate you step by step to create a sitemap.xml file in laravel.

Create a Sitemap Controller

In this step we will create SitemapController using following artisan command:

Now, we will create a index method to generate XML.

The sitemap.xml file


The next step is generating URL for the existing files, this will mean, the controller getting four methods which are similar as illustrated below,


Now we will create a product.blade.php inside the folder name sitemap and put the following code in it. Your sitemap/product.blade.php should look like this:


NOw, we will define some routes as following

Laravel 7/6 CKEditor with Image Upload

In this Laravel 7/6 CKEditor with Image Upload tutorial I will show you how to install and use CKEditor with image upload in laravel. In this tutorial, you will learn to install CKEditor in laravel using the command line. In this step by step guide I also show you how to upload images and files in laravel with CKEditor.

Laravel 7/6 CKEditor with Image Upload

  • Install Laravel
  • Install CKEditor Package in Laravel
  • Register CKEditor package in Laravel
  • Publish the Ckeditor package by command
  • Create Route
  • Generate Controller
  • Create Blade View
  • Upload and Insert Image in laravel using CKEditor

1. Install Laravel

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

2. Install CKEditor In Laravel

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

3. Register CKEditor package in Laravel

Now, we will register the package in laravel. Go to config/app.php and put the following line to the providers array.

4. Publish the Ckeditor package by command

Now run following command to copy some of the files and folders from ‘vendor\unisharp\laravel-ckeditor’ to ‘public\vendor\unisharp\laravel-ckeditor’.

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

6. Generate Controller

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

After successfully run the above command and create a controller file. Next open your controller and put the below code into your file.

7. Create Blade View

Now we go resource/views and create a file name ckeditor.blade.php. After this we will create a blade file now put the following code in it:

Note:- If the package of ckeditor is having some problem installing your Laravel web application. Then you add the following cdn file to your blade view file:

8. Upload and Insert Image in laravel using CKEditor

Now we have to enable image upload option in ckeditor as following:

Now we will create a route for upload the image in laravel using CKEditor.

Next, open your terminal and run the below command:

Next, we will put the below method in our controller name CKEditor. This method will store the image or files in the server and return the image URL.

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 –