rojib
rojib

Reputation: 377

Laravel Delete NotFoundHttpException

delete request could not, and appears NotFoundHttpException, why ?

Route::

Route::delete('hapus_user/{id}',array('as' => 'delete_user', 'user' => 'UserController@destroy'));

Controller:

public function destroy($id)
{
    $user3 = User::find($id);

    $user3->delete();

    return Redirect::to('user');
}

view :

<a href="<?php echo url('/user/hapus_user/'.$user->id_user); ?>">Hapus</a>

Upvotes: 0

Views: 189

Answers (1)

Osama Sayed
Osama Sayed

Reputation: 2023

You have a typo in your route user. change this:

'user' => 'UserController@destroy')

To:

'uses' => 'UserController@destroy')

And you are using in your url the prefix '/user/' before the url of the route while it doesn't exist in the route configuration. Change this:

<a href="<?php echo url('/user/hapus_user/'.$user->id_user); ?>">Hapus</a>

To:

<a href="<?php echo url('/hapus_user/'.$user->id_user); ?>">Hapus</a>

Hope this helps.

Upvotes: 2

Related Questions