Laravel 'usertype' Unknown word

25 views Asked by At

So I am doing basic authentication but where I am using 1 for admin and else for others but it is unable to detect "usertype" which i have created in my DB

This is Homecontroller.php

<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
use App\Models\User;

class HomeController extends Controller
{
    public function redirect(){
        $usertype = Auth::user()->usertype;

        if ($usertype == '1') {
            return view('admin.home');
        } else {
            return view('dashboard');
        }
    }
}

this is web.php

<?php

use Illuminate\Support\Facades\Route;
use App\Http\Controllers\HomeController;

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

Route::middleware([
    'auth:sanctum',
    config('jetstream.auth_session'),
    'verified',
])->group(function () {
    Route::get('/dashboard', function () {
        return view('dashboard');
    })->name('dashboard');
});

Route::get('/redirect', [HomeController::class, 'redirect']);

I also changed the RouteService Provider from

public const HOME = '/dasboard'; to this: public const HOME = '/redirect';

Can anyone please help

I tried to fix this according to documentation and I want to go to admin home when admin login but it goes to the normal user dashboard always

0

There are 0 answers