Laravel Lumen Call to undefined function App\Http\Controllers\back()

6.7k views Asked by At

Hello so I am working on my own authentication system using Laravel's lumen and getting the error Call to undefined function App\Http\Controllers\back() whenever I try to login with wrong credentials. This what my function looks like in my controller:

public function loglink(Request $request) {
    $input = $request->all();
    $user = array(
        'username' => $input['username'],
        'password' => $input['password']
    );

     if (Auth::attempt($user)) {
        $user = Auth::user();
        return view('auth.welcome', compact('user'));
     } else {
         return back()->withInput();
     }
 }

Is there something I need to include/call in my controller?

1

There are 1 answers

3
Limon Monte On BEST ANSWER

You can use back() shortland in Laravel only for now. For Lumen you need to add redirect():

return redirect()->back()->withInput();

Read more: http://lumen.laravel.com/docs/responses#redirects