Tag

Tutorial

Browsing

Today, I am going to tell you about the “Laravel Call undefined method lists Illuminate\Database\Query\Builder::lists()” error and going to share solutions with you.

When I am working with Laravel many times I used the eloquent “lists” method for getting the lists of the names like the country name with the ID as the key like.

When I am trying the use the lists method on the laravel 5.3 I am getting the error  “Laravel Call undefined method Illuminate\Database\Query\Builder::lists()” like

Laravel Call undefined method lists

When I search for this error I found that the “lists” method is removed from the Laravel 5.3. Now, we get the same lists data using pluck method form the Laravel 5.3 like

Finally, We are getting the solution use pluck method instead of the lists. Still, if you face any issue write the comment below.

Today, We are going to learn how to use laravel by creating Laravel 5 Hello World Application step by step. In this, we are going through the basic of Laravel 5 Hello World application by creating Laravel Route, Controller, View.

Introduction

Laravel is a full-framework for all kind of application. Hence, Laravel is the most popular highest rating framework on Github. Laravel is easy to use, with a simple learning curve, and a minimum number of steps required to get an app or website up and running.

First of all, We are going to install Laravel by following this steps.

Laravel 5 Hello World Application

We are going to learn Laravel 5 Hello World Application step by step.

Route

A route is a URL pattern that is mapped to a handler. Laravel route directs an incoming request to function or controller. Also, a route is a store on the “routes” directory. Let’s create the route for Hello World Application.

Let’s Open “routes/web.php” file for creating the route.

Laravel allow us to call view file directly from the Route. Now, let’s create the route that calls view file from Controller.

Finally, The Route is ready for “Hello World” application Now, Let’s move for the Controller.

Controller

Instead of defining all of your logic in the route files,  You may wish to create Controller class for organizing the logic. Controllers can group related request handling logic into a single class. Controllers are store in the app/Http/Controllers directory.

Let’s create the “HelloworldController.php” File at the “app/Http/Controllers” Folder or else we can generate Controller file by following artisan command like

After, Creating the Controller let’s create the “HelloWorld” method like

Finally, We are ready with Controller. We just call view file using Controller class instead of the Route. Now, let’s we are going to create the view file.

View

View file contains the HTML served by your application and separate your controller/application logic from your presentation logic. Views are store in the resources/views directory.

Finally, We are ready for the Laravel 5 Hello World Application. Now, let’s run the application and see the output.

Run laravel application by the following command

Now, Running the Laravel 5 application by following URL “http://localhost:8000/hello-world”

Output get something like this.

LaravelHive – Laravel 5 Hello World!