tim3011's avatar

routing how to index page in view /folder from the route

please could anyone guide me I have a route that I want to link to a page in views /folder the file is in the folder so as the controller is in controller /folder how do I reference this in route so far I have this

Route::get('/folder/login', 'AuthController@getSignin');
Route::post('/folder/login', 'AuthController@postSignin');

and on the controller I have this

public function getSignin()
    {
        // Is the user logged in?
        if (Auth::check())
        {
            return Redirect::route('welcome');
        }

        // Show the page
        return View('folder.login');
    }
0 likes
6 replies
SaeedPrez's avatar

Give your route a name..

Route::get('/folder/login', 'AuthController@getSignin')->name('folder.login');

Then you can redirect from a controller..

return redirect()->route('folder.login');

Or link to the route inside your blade template..

<a href="{{ route('folder.login') }}">folder login</a>
tim3011's avatar

@SaeedPrez sorry man no change keep getting the same error

Sorry, the page you are looking for could not be found.

1/1
NotFoundHttpException in RouteCollection.php line 161:

here is the route again

Route::post('/auth/login', 'AuthController@postSignin')->name('auth.login');
Route::get('/auth/login', 'AuthController@getSignin')->name('auth.login');

and here is the controller again

  public function getSignin()
    {
        // Is the user logged in?
        if (Auth::check())
        {
            //return Redirect::route('welcome');
            return redirect()->route('view.welcome');
        }

        // Show the page
        return View('auth.login');
       
    }
      
SaeedPrez's avatar

You've got it backwards..

This is telling Laravel to show the template /resources/views/auth/login.blade.php

return view('auth.login');

This is telling Laravel to redirect the user to a route named view.welcome

return redirect()->route('view.welcome');

If you name a route auth.login then you can redirect()->route('auth.login')

I suggest you invest some time to check the beginner tutorials at https://laracasts.com/series/laravel-5-from-scratch

1 like
tim3011's avatar

@SaeedPrez thanks for your help I have run the list controller command and got that my controllers do not exist the controllers are in controller and in folder auth {controller/auth/thecontroller.php} the command gives me this path

App\Http\Controllers\auth.AuthController does not exist
``
how do I reference   that on route

SaeedPrez's avatar

@tim3011

If I may be frank, your knowledge of Laravel is very limited and you lack even the very fundamentals. I think you will benefit a lot more if you invest some time in yourself and watch this video series a couple of times or until you understand it. It will save you a lot of future headaches and a lot of time.

Good luck.

tim3011's avatar

thanks much appreciated thats' how you learn next time I will know that

Please or to participate in this conversation.