Laravel 9 cannot get view to load after creating a record - returns view fails to load the 'games.index' route

Viewed 29

What is with Laravel 9 and my route not working. It is getting the right blade returning but it won't load the view onto the webpage. Appreciate any help as always.

Routes

Route::get('/', [EmployeeController::class, 'index'])->name('employees.index');
Route::get('/create', [EmployeeController::class, 'create'])->name('employees.create');
Route::post('/store', [EmployeeController::class, 'store'])->name('employees.store');

Controller

 public function index(Request $request, Response $res) {
        if ( $request->filled('search') )
        {
            $employees = Employee::search($request->search)->paginate(10);
            return view( 'employees.index', ['employees' => $employees] );
        } else{
            $games = Employee::paginate(10);
            return view( 'employees.index', ['employees' => $employees] );
        }
    }

    public function create(){
        return view('games.create');
    }

    public function store(Request $request)
    {
            $request->validate([
            'name'       =>'required|string|max:255',
            'boss_id'    =>'required|exists:bosses,id',
            'title'      =>'string|max:255',
            'role'       =>'required|in:RoleEnum',
        ]); 
        $employee = Employee::create([
            'name'       => $request->name,
            'boss_id'    => $request->boss_id,
            'title'      => $request->title,
            'role'       => $request->role,
        ]);
        
        return redirect('employees.index');
    }

Network debugger shows status method file 302 post store 200 get /

I can see the response in the window shows the games.index in its entirety but why won't it load it like it normally does? Thanks this laravel 9 has been beating me up.

1 Answers

I think it is related to Laravel cache

try these command's on your terminal:

php artisan cache:clear

php artisan route:clear

php artisan view:clear

Related