#Can't load /admin route

9 messages · Page 1 of 1 (latest)

crude fossil
#

I get the error of:

Permission denied The exception occurred while attempting to log: Target class [AdminController] does not exist

I have this in the route file web.php:

Route::middleware(['auth', 'verified', 'admin'])->group(function () {
Route::get('/admin', [AdminController::class, 'index'])->name('admin.dashboard');
});

AdminController.php is:

<?php

namespace App\Http\Controllers;
use Illuminate\Http\Request;
class AdminController extends Controller
{
public function index()
{
return view('admin.dashboard');
}
}

All files are in the correct directories and are spelt correctly.

Any ideas?

cunning cliff
#

Did you Import the Controller in your web.php

use App\Http\Controllers\AdminController;

crude fossil
#

OK.. That was a test. ;-p

#

Yes that was it. Thanks.

cunning cliff
#

No Problem 😉 we all start somewhere

crude fossil
#

Dont suppose you have an idea about this one?

Permission denied The exception occurred while attempting to log: Undefined variable $usersCount Context: {"view":{"view":"/var/www/html/app/resources/views/admin/dashboard.blade.php","data":[]},"userId":1,"exception":{}} Context: {"userId":1,"exception":{}}

#

<x-app-layout>
<x-slot name="header">
<h2 class="font-semibold text-xl text-gray-800 dark:text-gray-200 leading-tight">
{{ __(' Admin Dashboard') }}
</h2>
</x-slot>

<div class="py-12">
    <div class="max-w-7xl mx-auto sm:px-6 lg:px-8">
        <div class="bg-white dark:bg-gray-800 overflow-hidden shadow-sm sm:rounded-lg">
            <div class="p-6 text-gray-900 dark:text-gray-100">
            <h1>Welcome to the Admin Dashboard</h1>

<!-- <p>Total Users: {{ $usersCount }}</p> -->
<!-- Other dashboard content -->

            </div>
        </div>
    </div>
</div>

</x-app-layout>

#

Thats whats in the file

cunning cliff
#

There is a Line
<!-- <p>Total Users: {{ $usersCount }}</p> -->
That demands a usersCount which is not passed over the return view('admin.dashboard')
If you delete that line the error should be gone.
If you want to pass a Variable userCount you can do that in your controller like so:
return view('admin.dashboard', ['userCount', YOUR VARIABLE VALUE HERE]);