Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Laravel - return view in subfolder

I have got following lines:

Route::get('/dashboard', function () {
    return view('main.index');
});

But my view is located in main/sub/index.blade.php

I tried

Route::get('/dashboard', function () {
        return view('main.sub.index');
    });

also

 Route::get('/dashboard', function () {
        return view('main/sub.index');
    });

didnt work.

like image 809
uppermost Avatar asked Dec 11 '22 08:12

uppermost


1 Answers

Move the view to:

resources/views/main/sub/index.blade.php

Then this code will work:

Route::get('/dashboard', function () {
    return view('main.sub.index');
});

From the docs:

Views are stored in the resources/views directory. Since this view is stored at resources/views/greeting.blade.php, we may return it using the global view helper like so:

return view('greeting', ['name' => 'James']);
like image 97
Alexey Mezenin Avatar answered Dec 29 '22 17:12

Alexey Mezenin