简体   繁体   中英

Laravel routes messed up

I'm trying to navigate to a page I created for the logged in profile of a doctor. I have not put in any authentication as I want to take care of the front end first then move to that part of the project. So basically I wanted to navigate to those pages with just putting in the url in the browser but that's not working. I'm new to laravel and am working on a project that was a template first so I'm having a bit of trouble finding things and putting in the correct paths.

I've tried putting the path in the web.php and my PagesController in a few different ways but nothing has worked so far.

my web.php :-

Route::get('/login.profile', 'Frontend\PageController@loginProfile');

my PagesController :-

public function loginProfile(){
        $data['page_title'] = 'Profile';
        return view('frontend/login.profile');
    }

the path to the file :-

\Desktop\doctor\resources\views\frontend\login\profile.blade.php

Try to define the route like this:

Route::get('/login/profile', 'Frontend\PageController@loginProfile'); // I removed the dot from the url

and the controller method like this:

public function loginProfile(){
        $data['page_title'] = 'Profile';
        return view('frontend.login.profile', $data);
        // also view('frontend.login.profile')->withData($data)
        // and view('frontend.login.profile')->with(['data' => $data]) should work
        // You will have a $data array available in the template
}

the path to the controller should be app/Http/Controllers/Frontend/PageController.php and the path to the view should be resources/views/frontend/login/profile.php . When pointing to files, many Laravel method replace dots with slashes. That's a feature that's there to allow you to navigate/access stuff in a more "object-oriented" style, i would say. Let me know if it works.

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