0

Hello in laravel resource i have two views one is admin and users folder i can access both without any problem admin moves me to dashboard and users will access my default. here for accessing dashboard.

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

but in admin folder inside views i created

secondpage.balde.php

file which contains users info and in web routes i defined this

Route::get('userss', 'UsersController@show'); 

from admin dashboard when i goto userManagement or secondpage.blade.php using

<a class="p-2 text-white" href="userss">Manage Users</a>

artisan command to list routes works perfectly

|        | GET|HEAD | userss                 |                  | App\Http\Controllers\UsersController@show                         | web

laravel returns 404 | Not found. thanks

Folder Structure

resources have two folders admin and users. admin has views folder inside it users have views folder inside it generally resources**/admin/views** and /users/views the problem is accessing inside resources/admin/views

Khal
  • 219
  • 5
  • 19
  • 1
    `href="userss"` vs `href="/userss"` maybe? – brombeer Oct 28 '20 at 13:09
  • In your `Route::get` use `/userss` instead of `userss` – sceru Oct 28 '20 at 13:13
  • 1
    And I see a typo in your blade naming. You named your blade as `secondpage.balde.php` but it should be `secondpage.blade.php` – sceru Oct 28 '20 at 13:14
  • i tested it interchangeably on /userss and userss but not working – Khal Oct 28 '20 at 13:21
  • @aliozgurr That makes no difference `Route::get('/users')` is the same as `Route::get('users')` – brombeer Oct 28 '20 at 13:23
  • @khal Did you use `/userss` in the _href_ of your _link_ too? If you are at `admin/dash` a link with `href="userss"` will try to open `admin/userss` - which doesn't exist. A link with `href="/userss"` will try to open `/userss` - which _does_ exist – brombeer Oct 28 '20 at 13:26
  • @kerbh0Iz yes i used /userss – Khal Oct 28 '20 at 13:30
  • name your routes. Route::get('userss','UsersController@show')->name('routeName'); – Soroosh Noorzad Oct 28 '20 at 13:32
  • Assuming your server is running on localhost:8000, what do you get if you manually enter `http://localhost:8000/userss` in your adress bar? – brombeer Oct 28 '20 at 13:32
  • then call it on links href="{{route('routeName')}}" – Soroosh Noorzad Oct 28 '20 at 13:32
  • @Soroosh i name it but View [userss] not found. – Khal Oct 28 '20 at 13:37
  • ok. so can u give us your view folders to see what is going on? where is your userss.blade.php file? – Soroosh Noorzad Oct 28 '20 at 13:41
  • 1
    @Sorooshn updated the question put it in end of it thanks – Khal Oct 28 '20 at 13:48
  • Are you sure your `UsersController@show` is not using `Model::find()` or something related? These kind of functions return you a 404 as well if not found.(maybe run the function without code first) – Techno Oct 28 '20 at 13:51
  • 1
    You care calling `href="userss"` from `127.0.0.1:800/admin/dash` so your browser call the path `admin/dash/userss`, which is giving you a 404 error. So give a slash before the path, so that It can be call from root : `href="/userss"` as @kerbh0lz said already – STA Oct 28 '20 at 14:31

1 Answers1

-1

first set name for route

Route::get('userss', 'UsersController@show')->name('users'); 

next can call route function easy

<a class="p-2 text-white" href="{{route('users')}}">Manage Users</a>