Maxcot
Maxcot

Reputation: 1617

Laravel redirect fails, but direct route works

If I type carfreak/owner into my browser, the expected view comes up. An artisan route:list all looks good, and the fact the browser finds it means the route is working.

If I put any of the following, into my controller, I get route [...] not defined

What have I missed? Laravel documentation says it should work: https://laravel.com/docs/5.2/routing#named-routes

EDIT:

Upvotes: 0

Views: 46

Answers (1)

Martin
Martin

Reputation: 1279

I think that you can't use return redirect()->route('/owner'); or return redirect()->route('carfreak/owner');

If you redirect to a route then you need to pass route name which you set in your routes file by making 'as' => 'routename' and not use the route adress inside route redirect.

Upvotes: 1

Related Questions