在Laravel 5.6中找不到雄辩的模型类[关闭]

I keep getting the following error:

Use of undefined constant App - assumed 'App'

when I do:

  Route::get('/tasks', function () {
        $tasks = App / Task::all();
        return view('tasks.index', compact('tasks'));
    });

This is how my model look like and it is located in the root of app directory:

<?php

namespace App;

use Illuminate\Database\Eloquent\Model;

class Task extends Model
{
    //
}

Then if I change it to $tasks = 'App' / Task::all(); as it suggests then I get the class not found error:

"Class 'Task' not found"

I have no clue what´s wrong, but as I am following a 5.4 tutorial and I am working with 5.6 there must be something different.

Please help me.

App\Task::all();

compact('tasks')

here, is correction

 $tasks = App\Task::all(); 

and

 return view('tasks.index', compact('tasks'));

Namespaces are referenced with backslashes (\). So in your case you should use App\User::all();

You can take a look at this page for more info: http://php.net/manual/en/language.namespaces.php