11
votes

I had made the routes in routes.php file

Route::controller('auth','Auth\AuthController');

Auth/AuthController.php file is

<?php

namespace App\Http\Controllers\Auth;

use App\User;
use Validator;
use App\Http\Controllers\Controller;
use Illuminate\Contracts\Auth\Guard;

use App\Http\Requests\Auth\LoginRequest;
use App\Http\Requests\Auth\RegisterRequest;
use Illuminate\Foundation\Auth\ThrottlesLogins;
use Illuminate\Foundation\Auth\AuthenticatesAndRegistersUsers;

class AuthController extends Controller
{

use AuthenticatesAndRegistersUsers, ThrottlesLogins;

    /**
 * the model instance
 * @var User
 */
protected $user; 
/**
 * The Guard implementation.
 *
 * @var Authenticator
 */
protected $auth;

/**
 * Create a new authentication controller instance.
 *
 * @return void
 */
public function __construct(Guard $auth, User $user)
{

    $this->user = $user; 
    $this->auth = $auth;

    $this->middleware('guest', ['except' => ['getLogout']]); 
}

/**
 * Show the application registration form.
 *
 * @return Response
 */
public function getRegister()
{
    return view('auth.register');
}

/**
 * Handle a registration request for the application.
 *
 * @param  RegisterRequest  $request
 * @return Response
 */
public function postRegister(RegisterRequest $request)
{
    //code for registering a user goes here.
    $this->auth->login($this->user); 
    return redirect('/todo'); 
}

/**
 * Show the application login form.
 *
 * @return Response
 */
public function getLogin()
{
    return view('auth.login');
}

/**
 * Handle a login request to the application.
 *
 * @param  LoginRequest  $request
 * @return Response
 */
public function postLogin(LoginRequest $request)
{
    if ($this->auth->attempt($request->only('email', 'password')))
    {
        return redirect('/todo');
    }

    return redirect('/login')->withErrors([
        'email' => 'The credentials you entered did not match our records. Try again?',
    ]);
}

/**
 * Log the user out of the application.
 *
 * @return Response
 */
public function getLogout()
{
    $this->auth->logout();

    return redirect('/');
}
}

When I hit this auth/login it give me the error -- InvalidArgumentException in FileViewFinder.php line 137: View [auth.login] not found. Can anyone help me out to resolve this issue.?

6
What's your view folder structure look like? Laravel 5.1 doesn't come with Auth views out of the box anymore - Peter Fox
Thanks @PeterFox I am able to find out the problem. Thank you so much - Sakshi Garg
@PeterFox can you please, make available your findings and solution to the problem as it might help a lot o people, am having this same issue with the same code as above. Thank you. - femotizo

6 Answers

27
votes

Go to

bootstrap/cache

And rename config.php to config.php_

Im pretty sure you have copied from another site and moved also the cache

7
votes

if you just startet a new project, there aren't auth views out of the box, just as Peter Fox mentioned above.

You will need to enter

php artisan make:auth

to create these views.

2
votes

i got mine to work after modifing the auth.login directroy from /Auth to /auth can be located at laravel/resources/views/Auth

2
votes

This may happened when we are going to do fresh setup. try cleaning first

php artisan view:clear

php artisan config:cache

php artisan route:cache
1
votes

In your file web.php inside the directory routes, delete or comment the line Auth::routes();

0
votes

if you are in develop mode you can run:

php artisan config:clear

or if you are in product mode you can run bellow code:

php artisan config:cache

notice: when you use second, config clear and cache again and you force to repeat command for other changes.