I've created todo app in laravel in which there's a delete button. Whenever I add data, it works, shows in the table. But after clicking delete button, other data are appearing not in table.
ToDosController
public function index(Request $request)
{
$userid = $request->user()->todos()->get(['id']);
$arr = ToDo::whereIn('user_id', $userid)->paginate(5);
$count['counts'] = ToDo::whereIn('user_id', $userid);
$pending = ToDo::where('status', 'Pending');
$completed = ToDo::where('status', 'Completed');
return view('admin.todo.index')->with('todos',$arr)->with($count)->with('pending',$pending)->with('completed',$completed)->with((array('user' => Auth::user())));
}
View
<div class="box-body table-responsive no-padding">
<table class="table table-hover">
<tr>
<th>Status</th>
<th>Title</th>
<th>Description</th>
<th>Schedule</th>
<th>Deadline</th>
<th>Action</th>
</tr>
@if(count($todos) > 0)
@foreach($todos as $td)
<tr>
<td>
@if($td->status == 'Pending')
<span class="label label-danger"></span></td>
@elseif($td->status == 'Completed')
<span class="label label-success"></span></td>
@endif
</td>
<td></td>
<td></td>
<td></td>
<td></td>
<td>
<a href="" class="btn btn-info">Edit</a>
<a href="javascript:void(0)" onClick="$(this).parent().find('form').submit()" class="btn btn-danger">Delete</a>
<a href="" class="btn btn-info">Show</a>
<form action="" method="post" value="DELETE">
</form>
</td>
</tr>
@endforeach
You can see in image that it's showing pending todo, completed todo but it's not showing them in table.
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire