Tag

Laravel

Browsing

Today, We are going to learn Laravel Extract zip/archive file using chumper/zipper. In the last article, we will learn how to create a zip file.  Also, We are going to use chumper zipper package to extract the zip file. First of all, We are going to install the package by the following command.

Laravel Extract zip/archive file using chumper/zipper

Once the package has installed we have to update the Providers and Aliases. Let’s open the config “config/app.php” file then append the Providers and Aliases like below.

The Chumper Zipper package is ready to use. Now, We going to extract the zip file. Let’s create the function to extract the zip file.

First of all, I get the zip file path for passing the first argument on the Zipper function. As a second argument, You should pass the valid directory where you want to extract the zip file. Now, run the code and check the zip file is an extract or not.

If you face any issue on extract zip file please write the comment below.

Today, We are going to learn Laravel 5 Hello World application. We all hear about the Laravel Framework. Laravel is the most popular object-oriented PHP Framework. Laravel is easy for developing the application and secure framework. We are going to learn step by step Hello World application of Laravel. First of all, We are going to install Laravel.

The composer is required for installing Laravel application. If the composer is not installed then install it first.

Laravel 5 Hello World application

Let’s see how to install the latest version of the Laravel

If you want to install an older version of the Laravel then follow below command.

You have to pass the folder name for installing Laravel my folder name is thecodingstuff. You can change or replace the command with your folder name.

Once the Laravel installation is complete just goto the project directory by the following command.

Now, Let’s run the Laravel project follow the command

Now, You can access the Laravel project by following the link.

If you want to run the Laravel project directly without firing any command. You can follow the below link.

Now, We are going to create the route, controller and view file code. First of all, Let’s create the route.

Create Route

Open the laravel route file for create route. If you install Laravel 5.3 or above version then you will find the route file at “routes/web.php” location. If you install Laravel 5.2 or lower version then you will find the route at “app/Http/routes.php” location.

Let’s open your route file and write the route like.

Laravel provides all types of routes like GET, POST, UPDATE, DELETE etc.. For Now, we create the GET route for Hello World application. The first parameter is the URL prefix “hello-world” and the second parameter is the Controller name and function name.

Create Controller

Let’s create the controller for Hello World example. Create a new file at “app/Http/Controllers/ExampleController.php” location. Now, open the ExampleController.php and write the below code.

Create View

Now, We are going to create a view file. Create a new file at “resources/example.blade.php” location. Open example.blade.php file then writes below code.

The Hello World example is over Now, let’s run the application and check the Hello World example. Open below URL

If you get any error on this page writes the comment below.

Today, We are going to learn how to find the records between two different numbers like find the product that price is between 5 to 25. So, Let’s see how we can find the records between two numbers. MySQL between two numbers in Laravel. We can find the records between two numbers using two ways in Laravel. Let’s see the first way how we can find the records between two numbers.

MySQL between two numbers in Laravel

You can achieve the same result using less than and greater than instead of whereBetween function. let’s see the second way for finding the records.

You can achieve the same result on the both example. So, it’s too easy to find the product between two number.

If you face any issue after using this query please write the comment below.

Today, We are going to learn how we can find the number between two columns in Laravel. Many times we need to find the number between two columns like from and to. Laravel allows us to write complex MySQL query using DB RAW. Let’s how we can write the query for MySQL BETWEEN Two Columns in Laravel.

MySQL BETWEEN Two Columns in Laravel

Just follow the query for finding the number between two columns.

Also, We can find the number between two column using another way like.

Both queries are working fine with Laravel for finding the number between two columns. I hope the article is helpful to you.

If you face any issue after following the query please write the comment.

Laravel is the fastest growing PHP Framework and Object-oriented framework and provides a rich library. Laravel provides a best validation library using that we can easily validate the incoming request. Today, We are going to learn about the unique validation of Laravel. Laravel unique validation is preventing from the duplicate value on the database. You can easily check the record is exists on the database or not? Using Laravel unique validation. Many times we need set the unique validation for Email, Phone, Slug, SKU etc…

Laravel unique validation

So let’s see how we can use Laravel unique validation. I want to set the unique validation on the slug field then let’s follow the validation rule.

We set the unique validation on slug field. Slug field is very useful when we are working with Blog, Product etc… module. Now, Laravel check for the slug on the database that the slug exists or not? If the slug exists then Laravel fire validation like”The slug has already existed”. So, it’s too easy to set unique validation on Laravel.

Now, Let’s write the unique validation for edit record. We need to change the validation value when we are working on edit functionality. We need to pass the current active record ID as a parameter on validation. Now, Let’s change the unique validation during edit functionality like.

Now, Let’s assume I want to edit the 7 number product then Laravel fire unique validation query like below.

select * from product where slug = ‘simple-product’ and id <> 7;

Now, Check the unique validation working perfectly with edit record functionality.

If you face any issue on Laravel unique validation please write the comment below.