laravel5.2 Auth :: guest()返回错误“Class'App \ Http \ Controllers \ Auth'not found”

I am trying to use the inbuilt Auth for login in laravel and register. These automatically generated pages work so well, now I use Auth::guest() to check if the user is authorized to return a view: index else to login page.

But it shows:

Class 'App\Http\Controllers\Auth' not found".

Here's the code:

<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use App\Http\Requests;
use App\Http\Controllers\Auth;
use App\Http\Controllers\Controller;

class StepsController extends Controller
{
    public function step1()
    {
        if (Auth::guest())
        {
            return redirect('login');
        }else {
            return view('index');
        }
    }
}

You need to "import" the definition of the facade of Auth and remove the use App\Http\Controllers\Auth because does not exists.

Just add at the top (just before the class declaration):

use Auth;

And remove the other:

Having this:

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use App\Http\Requests;
use App\Http\Controllers\Controller;
use Auth;

class StepsController extends Controller
{
....

Hope it helps.

PS: If you want to learn Laravel with a good guide, step-by-step, please check here: Learn Laravel