Creating View in Laravel

November 20, 2017

In this lesson we will see how to create a controller in Larevel and then create a view to show data with action controller

Now we will first create a controller called BookController

You can run following command inside the terminal

php artisan make:controller BookController

This will create the following code

Now I will create the action controller to load the view by passing array

class BookController extends Controller
    public function index(){

    	return view('book.index', ['books' => array("Book A","Book B","Book C")]);


Now you can create the index.blade.php file inside the resources>view>book folder


List of Books

    @foreach($books as $k => $v)
  • {{ $v }}
  • @endforeach

Finally you can see the following output in your