Orik3ll0
Orik3ll0

Reputation: 77

Laravel 5.4 controller doesn`t show page

I have folder "aboutus" which contains 'index.blade.php' file and folder "thanks". Folder "thanks"contains also 'index.blade.php'

My route for both of them:

    Route::resource('admin/aboutus', 'AdminAboutusController',['names'=>[

        'index'=>'admin.aboutus.index',
        'create'=>'admin.aboutus.create',
        'store'=>'admin.aboutus.store',
        'edit'=>'admin.aboutus.edit'
    ]]);

    Route::resource('admin/aboutus/thanks', 'AboutThanksController',['names'=>[

        'index'=>'admin.aboutus.thanks.index',
        'create'=>'admin.aboutus.thanks.create',
        'store'=>'admin.aboutus.thanks.store',
        'edit'=>'admin.aboutus.thanks.edit'
    ]]);

I have created controller for aboutus and thanks separately (AdminAboutusController and AboutThanksController)

AdminAboutusController index funnction returns view which i am able to see

public function index() { return view('admin.aboutus.index'); }

But controller AboutThanksController doesn`t shows me my page, it shows me white blank

public function index() { return view('admin.aboutus.thanks.index'); }

on php artisan route:list i can see that route is aviable. Why it happens and how can I fix it?

Upvotes: 0

Views: 84

Answers (3)

Leena Patel
Leena Patel

Reputation: 2453

Put thanks route above about us route

Route::resource('admin/aboutus/thanks', 'AboutThanksController',['names'=>[

    'index'=>'admin.aboutus.thanks.index',
    'create'=>'admin.aboutus.thanks.create',
    'store'=>'admin.aboutus.thanks.store',
    'edit'=>'admin.aboutus.thanks.edit'
]]);
Route::resource('admin/aboutus', 'AdminAboutusController',['names'=>[

    'index'=>'admin.aboutus.index',
    'create'=>'admin.aboutus.create',
    'store'=>'admin.aboutus.store',
    'edit'=>'admin.aboutus.edit'
]]);

Upvotes: 1

Jahid Hasan
Jahid Hasan

Reputation: 653

using route:list you are able to see list of routes but return view() function don't take route as a parameter. You have to give the file name and path.For example you want to show thanks.blade.php file which is inside admin/aboutus of your view folder. So you have to write:

return view('admin.aboutus.thanks');

Upvotes: 0

Mihir Bhende
Mihir Bhende

Reputation: 9045

Posting as an answer to close the question:

You have admin.aboutus.thnx.index but your folder is admin/aboutus/thanks/index

Please change to admin.aboutus.thanks.index and it should work

Upvotes: 0

Related Questions