Hard Tacos
Hard Tacos

Reputation: 370

Laravel Routes returning a 404 with route parameters

This is not the first time that I have used route parameters in laravel, however I cannot seem to get this to work.

Route:

Route::group(['prefix' => 'admin', 'before' => 'auth|beta|admin'], function()
{
    Route::post('remove/{$id}', ['uses' => 'AdminController@postRemoveID', 'as' => 'admin.postremoveid']);
});

Controller:

public function postRemoveID($id)
 {
    $remove = ServiceProvider::where('id','=',$id)->first();
    $remove->delete();

    return Redirect::route('admin.manage'); //This just redirects to the page the user is currently on
 }

Blade:

<a href="{{ route('admin.postremoveid', $id) }}">
    <i class="fa fa-times"></i>
</a>

What would be causing my site to be redirecting to a 404?

Thanks for all your help!! -Patrick

Upvotes: 1

Views: 4176

Answers (2)

mydo47
mydo47

Reputation: 379

Use Route:get();

  Route::get('remove/{id}', ['uses' => 'AdminController@getRemoveID', 'as' => 'admin.postremoveid']);

Controller:

public function getRemoveID($id)
 {
    $remove = ServiceProvider::where('id','=',$id)->first();
    $remove->delete();

    return Redirect::route('admin.manage'); //This just redirects to the page the user is currently on
 }

Upvotes: 2

nilobarp
nilobarp

Reputation: 4094

You don't need that $ on the wild card

Route::group(['prefix' => 'admin', 'before' => 'auth|beta|admin'], function()
{
     Route::post('remove/{id}', ['uses' => 'AdminController@postRemoveID', 'as' => 'admin.postremoveid']);
});

Upvotes: 2

Related Questions