简体   繁体   中英

return view() doesn't work in laravel 5

I'm getting Use of undefined constant dashboard - assumed 'dashboard' after

public function login()
    {
        $email = Input::get('email');
        $password = Input::get('password');

        if (Auth::attempt(['email' => $email, 'password' => $password]))
        {
            return view(dashboard);
        }
        else
            return 'nope';

    }

It was working when in my subscriber model I had

Class Subscriber extends Model

But after changing that to

class Subscriber extends \Eloquent implements Authenticatable

returning view() in controller no longer works.

Your error is saying that dashboard is undefined. The error also suggests that you try quoting dashboard, like so:

'dashboard'

You are missing the quotes around dashboard.

if (Auth::attempt(['email' => $email, 'password' => $password]))
{
  return view('dashboard');
}

If dashboard is nested within a folder mention it likewise:

if (Auth::attempt(['email' => $email, 'password' => $password]))
{
  return view('folderName.dashboard');
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM