type php artisan route:list in the console and see if that gives you any indication about what's wrong
Apr 20, 2018
17
Level 1
Base route (/) under prefix
Hi all!
I'm having problems when I try to reach the base route of the admin panel I'm building.
Suppose that I have it on: http://localhost/admin/
When I type that URL, I get a Forbidden error page. That doesn't happen when I visit the Auth routes, the dashboard route and general one for controller/action.
I use Laravel 5.5.
This is the interesting code fragment of my web.php:
Route::prefix('admin')->group(function () {
Auth::routes();
Route::middleware(['auth'])->group(function () {
Route::namespace('Admin')->group(function () {
Route::get('/', 'PageController@dashboard')->name('panel'); // Added name
Route::get('/dashboard', 'PageController@dashboard')->name('dashboard');
Route::get('/{controller}/{action?}', 'PageController@action')->where([
'controller' => '[a-z]+(?:-[a-z]+)*',
'action' => '[a-z]+(?:-[a-z]+)*'
]);
});
});
});
This is a snippet of Admin\PageController.php:
<?php
namespace App\Http\Controllers\Admin;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use Auth;
use \App\Data;
class PageController extends Controller
{
public function dashboard() {
if (Auth::check()) {
$data = Data::all();
return view('admin/dashboard')->with('data', $data);
}
return redirect()->route('login');
}
public function action($controller, $action = 'index') {
if (Auth::check()) {
return studly_case('controller') . 'Controller' . '@' . $action;
}
return redirect()->route('login');
}
}
And this is the output of php artisan route:list:
Laravel routes list
Thanks in advance!
Level 122
just check that you dont have a folder called admin in your public folder
Please or to participate in this conversation.