Laravel PHP Error 404 not found in laravel-8

Viewed 2401

in my code is

enter image description here then when I click to edit or delete, I found 404 not found on my website like this one this is an error problem for me

enter image description here

and in code route

web.php

 Route::get('/rekaman/blog/edit/{$id}','BlogController@edit');

Route::get('/blog/{$id}/hapus','App\Http\Controllers\BlogController@destroy');

and then this my code for BlogController

public function edit($id)
{
    $artikel = Blog::find($id);
    return view('blog.blog_edit', ['artikel' => $artikel]);
}
public function destroy($id)
{
    $artikel = Blog::find($id);
    $artikel->delete();
    return redirect('/rekaman/blog')
    ->with('success','Artikel Anda Sudah Kami Hapus');
}

I hope you can help me Thank you

3 Answers

Remove dollar sign from routing. So replace {$id} to {id}

Route::get('/rekaman/blog/edit/{id}','BlogController@edit');
Route::get('/blog/{id}/hapus','App\Http\Controllers\BlogController@destroy');

Try removing the $ in your $id e.g. Route::get('/rekaman/blog/edit/{id}','BlogController@edit');.

Then run php artisan route:clear

You have to update your routes

Route::get('/rekaman/blog/edit/{id}','BlogController@edit');

Route::get('/blog/{id}/hapus','App\Http\Controllers\BlogController@destroy');

then run command php artisan optimize

then you got your solution

Related