Laravel 5.1 blade is not working even after including laravel Collective Laravel 5.1 blade is not working even after including laravel Collective laravel laravel

Laravel 5.1 blade is not working even after including laravel Collective


You may be missing use App\Task; at the top of your routes.php file.

I had the exact same issue, Class 'Task' not found and this fixed it.Ensure that your task::orderBy.... is the correct capitalisation too.

Here's the first route from mine for example:

use App\Task;use Illuminate\Http\Request;/** * Display All Tasks */Route::get('/', function () {    $tasks = Task::orderBy('created_at', 'asc')->get();    return view('tasks', [        'tasks' => $tasks    ]);});


Be sure of:

  • Name it Task instead of task
  • Include use App\Task inside your routes.php
  • Include namespace at the first line in Task.php: namespace App; (if you have the models in App, of course)


The problem is you are trying to access the view directly, which is not how Laravel works. You need to setup the route and access that route, which returns the view that you want.

For example, go to app/Http/routes.php. This is your routes file. In it, you can add something like this:

// The "test" is the uri. Keep this in mind.// Think of it as the appended URL.// So, it would be something like www.example.com/testRoute::get('test', function () {    // I am returning the view here.    // Note that I am returning "tasks", not "tasks.blade.php".    return view('tasks');});

Then, based on your image, you would need to access this route here: http://localhost/laravel/public/test

If you change the URI to something like "tasks":

// Changing "tests" to "tasks"Route::get('tasks', function () {    // Note that I am returning "tasks", not "tasks.blade.php"    return view('tasks');});

Then you access it at http://localhost/laravel/public/tasks

Read the docs on routing for a full breakdown on the subject: http://laravel.com/docs/5.1/routing