0

So, I have a single page for every database row on my website. When I look at this single page I have created a button to delete the specific row from the database. For this case, it's id 17.

I'm using Laravel 5.4

How do I do this? I get this error: NotFoundHttpException in RouteCollection.php line 161:

My routes:

Route::get('/deleteSite{id}', 'ScanController@delete');

Controller:

public function delete($id) {

        $scan = Scan::find($id);
        $scan->delete();

        return redirect('home');

    }

My url: http://seo.website.nl/deleteSite/17?(17 is the id that i want to delete, why is the question mark here?)

Button:

 <form method="GET" action="/deleteSite/{{$scan->id}}"><button type="submit" class="btn btn-danger">Delete</button></form>

Thanks in advance.

2 Answers 2

1

In your routes you forgot to add / between deleteSite and {id}.

Change it to this:

Route::get('/deleteSite/{id}', 'ScanController@delete');
Sign up to request clarification or add additional context in comments.

1 Comment

Omg... Hours searching for the problem and it's a typo.... Thanks dud! Appreciate ya!
0

Your route is missing a slash:

Route::get('/deleteSite{id}', 'ScanController@delete');
                      ^

change it to

Route::get('/deleteSite/{id}', 'ScanController@delete');
                       ^

Also your code is against restfull pattern. Search about it.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.