i get this error when i tried to access the admin/dashbaord
here is my web.php
<?php
use Illuminate\Support\Facades\Route;
use App\Http\Controllers\TransactionController;
use App\Http\Controllers\Auth\RegisteredUserController;
use App\Http\Controllers\WalletController;
use App\Http\Controllers\InvoiceController;
use App\Http\Controllers\ProfileController;
use App\Http\Controllers\AdminAuthController;
use App\Http\Controllers\AdminUserController;
use App\Http\Controllers\AdminTransactionController;
use App\Http\Controllers\AdminInvoiceController;
/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/
// Public home page
Route::get('/', function () {
return view('welcome');
});
// Authentication Routes for Regular Users
require __DIR__ . '/auth.php';
// Routes for regular user registration
Route::get('/register', [RegisteredUserController::class, 'create'])->name('register');
Route::post('/register', [RegisteredUserController::class, 'store']);
// Routes for authenticated regular users
Route::middleware('auth')->group(function () {
Route::get('/dashboard', function () {
$user = auth()->user();
// Wallet balances
$wallets = $user->wallets;
// Recent transactions
$recentTransactions = \App\Models\Transaction::with(['sender', 'receiver'])
->where('sender_id', $user->id)
->orWhere('receiver_id', $user->id)
->orderBy('created_at', 'desc')
->take(5)
->get();
// Pending invoices
$pendingInvoices = \App\Models\Invoice::where('user_id', $user->id)
->where('status', 'Pending')
->orderBy('created_at', 'desc')
->take(5)
->get();
return view('dashboard', compact('wallets', 'recentTransactions', 'pendingInvoices'));
})->name('dashboard');
// Wallet routes
Route::get('/wallet', function () {
$wallets = auth()->user()->wallets;
return view('wallet.index', compact('wallets'));
})->name('wallet.index');
Route::get('/wallet/history', [WalletController::class, 'history'])->name('wallet.history');
Route::post('/wallet/topup', [WalletController::class, 'topUp'])->name('wallet.topup');
// Transaction routes
Route::get('/transactions', [TransactionController::class, 'index'])->name('transactions.index');
Route::get('/transactions/{id}', [TransactionController::class, 'show'])->name('transactions.show');
Route::post('/transfer', [TransactionController::class, 'transfer'])->name('transfer');
// Invoice routes
Route::get('/invoices', [InvoiceController::class, 'index'])->name('invoices.index');
Route::get('/invoices/create', [InvoiceController::class, 'create'])->name('invoices.create');
Route::post('/invoices', [InvoiceController::class, 'store'])->name('invoices.store');
Route::get('/invoices/{invoice}/pay', [InvoiceController::class, 'pay'])->name('invoices.pay');
// Profile Management Routes
Route::get('/profile', [ProfileController::class, 'edit'])->name('profile.edit');
Route::post('/profile', [ProfileController::class, 'update'])->name('profile.update');
});
// Admin Authentication and Routes
Route::prefix('admin')->group(function () {
// Admin Login Routes
Route::get('/login', [AdminAuthController::class, 'showLoginForm'])->name('admin.login');
Route::post('/login', [AdminAuthController::class, 'login'])->name('admin.login.submit');
Route::post('/logout', [AdminAuthController::class, 'logout'])->name('admin.logout');
// Admin Dashboard and Protected Routes
Route::middleware('admin')->group(function () {
Route::get('/dashboard', function () {
return redirect()->route('admin.dashboard');
})->name('admin.dashboard');
// Admin User Management
Route::get('/users', [AdminUserController::class, 'index'])->name('admin.users.index');
Route::get('/users/{id}', [AdminUserController::class, 'show'])->name('admin.users.show');
Route::post('/users/{id}/update', [AdminUserController::class, 'update'])->name('admin.users.update');
Route::post('/users/{id}/delete', [AdminUserController::class, 'delete'])->name('admin.users.delete');
// Admin Transaction Management
Route::get('/transactions', [AdminTransactionController::class, 'index'])->name('admin.transactions.index');
Route::get('/transactions/{id}', [AdminTransactionController::class, 'show'])->name('admin.transactions.show');
// Admin Invoice Management
Route::get('/invoices', [AdminInvoiceController::class, 'index'])->name('admin.invoices.index');
Route::get('/invoices/{id}', [AdminInvoiceController::class, 'show'])->name('admin.invoices.show');
Route::post('/invoices/{id}/update', [AdminInvoiceController::class, 'update'])->name('admin.invoices.update');
});
});
here is AdminMiddleware.php
<?php
namespace App\Http\Middleware;
use Closure;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
class AdminMiddleware
{
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle(Request $request, Closure $next)
{
if (Auth::guard('admin')->check()) {
return $next($request);
}
return redirect()->route('admin.login');
}
}
here is Admin.php
[
'guard' => 'web',
'passwords' => 'users',
],
'guards' => [
'web' => [
'driver' => 'session',
'provider' => 'users',
],
'admin' => [
'driver' => 'session',
'provider' => 'admins',
],
],
'providers' => [
'users' => [
'driver' => 'eloquent',
'model' => App\Models\User::class,
],
'admins' => [
'driver' => 'eloquent',
'model' => App\Models\Admin::class,
],
],
'passwords' => [
'users' => [
'provider' => 'users',
'table' => 'password_resets',
'expire' => 60,
'throttle' => 60,
],
'admins' => [
'provider' => 'admins',
'table' => 'password_resets',
'expire' => 60,
'throttle' => 60,
],
],
'password_timeout' => 10800,
];
```
```
```
tried al posisble but no solution