06.10.2016 Views

laravel-5

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Basic Task List 93<br />

1 <br />

Deleting The Task<br />

Finally, let’s add logic to our route to actually delete the given task. We can use implicit model<br />

binding to automatically retrieve the Task model that corresponds to the {task} route parameter.<br />

In our route callback, we will use the delete method to delete the record. Once the record is deleted,<br />

we will redirect the user back to the / URL:<br />

1 Route::delete('/task/{task}', function (Task $task) {<br />

2 $task->delete();<br />

3<br />

4 return redirect('/');<br />

5 });

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!