0

Hello i have two folders in resources folder in laravel one is front end and other is back end which is admin folder.But accessing views from admin folder generates error when accessing view via controller View [login] not found. here is my folder structure for admin panel. Resources -> admin -> views -> login.blade.php for front end Resources -> views->welcome.blade.php

on Logincontroller

class Logincontroller  extends Controller
{
    public function index()
    {
     return view('login');
    
    }
}

i have tried also return view('admin/login');

but web route works perfectly

Route::get('admin/login', function () {
    return view('login');
});

and below Route generates error Route::get('/login', 'Logincontroller@index');

4
  • 1
    this isn't how views are structured, they are in the resources/views directory ... if you want to have them some where else you would have to configure the application to know that Commented Nov 19, 2020 at 8:06
  • @lagbox i have configured the app thats why Route::get('admin/login', function () { return view('login'); }); works perfectly. if there is error please tell me Commented Nov 19, 2020 at 8:14
  • there is no view named login in resources/views that is why ... it only looks for views in resources/views ... if it isn't in there somewhere then it doesn't exist Commented Nov 19, 2020 at 8:15
  • You probably do have a view called login under resources/views or you somehow changed the root of your views. You should move your admin views in resources/views/admin and then you can access them via e.g. view('admin.login') Commented Nov 19, 2020 at 8:48

1 Answer 1

1

The structure should be like : resources/views/admin/login.blade.php

And the usage should be like : return view('admin.login');

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.