Welcome ! I'm new to laravel and i have problem. I start my private project and i want to delete query from database using delete button ( simple todo app). When i click it it doesn't delete but only redirect me to id of this query. Dont know what to do. Can someone help me?
Regards tomczas
Destroy function in homecontroller
public function destroy($id)
{
$todo = Todo::findOrFail($id);
$todo->delete();
return back();
}
home blade
@foreach($todos as $todo)
<ul class="todo-list">
<li>
<!-- drag handle -->
<span class="handle">
<i class="fa fa-ellipsis-v"></i>
<i class="fa fa-ellipsis-v"></i>
</span>
<!-- checkbox -->
<input type="checkbox" value="">
<!-- todo text -->
<span class="text">{{$todo->tytul}}</span>
<!-- Emphasis label -->
<small class="label label-danger"><i class="fa fa-clock-o"></i> {{$todo->czas}}</small>
<!-- General tools such as edit or delete-->
<div class="tools">
<i class="fa fa-edit"></i>
{{Form::open([ 'method' => 'DELETE', 'route' => [ 'home.destroy', $todo ] ])}}
{{ Form::hidden('id', $todo->id) }}
{{Form::button('<i class="fa fa-trash-o"></i>', array('type' => 'submit', 'class' => ''))}}
{{ Form::close() }}
<i class="fa fa-trash-o"></i>
</div>
</li>
</ul>
@endforeach