我有3张桌子。
Dim FadeTimers As New List(Of Timer)({Fade_0, Fade_1, Fade_2...})
中的如下
FadeTimers(KeyIndex).start()
我想用attendance_worker
删除id | worker_id | attendance_id | info
1 2 1 present
2 3 1 present
3 2 2 present
4 3 2 absent
我应该在控制器中做什么来分离该单行?我真的对逻辑不好,我是来这里学习幼虫的新手
这是我的控制人
worker_id=3
这是我的刀片的屏幕截图
答案 0 :(得分:0)
您的表格:
<table class="table table-hover table-in-card">
<thead>
<tr>
<th scope="col">No</th>
<th scope="col">Name</th>
<th scope="col">Info</th>
<th scope="col" class="">Action</th>
</tr>
</thead>
<tbody>
@foreach($attendance->worker as $key->$worker)
<tr>
<th scope="row">{{ $key+1 }}</th>
<td>{{$worker->name}}</td>
<td>{{$worker->pivot->info}}</td>
<td>
<form method="post" action="{{route('worker.delAttend',['worker'=>$worker->id,'attend'=>$attend->id])}}">
@method('DELETE')
@csrf
<button class="btn btn-warning btn btn-danger btn-sm" type="submit"><i class="fas fa-trash-alt"></i></button>
</form>
</td>
</tr>
@endforeach
</tbody>
</table>
您的路线:
Route::delete('/d/{worker}/{attend}',[Controller::class,'deleteattendance'])->name('worker.delAttend');
您的控制器:
public function deleteattendance(WorkerModel $worker, AttendModel $attend){
$attend->Worker()->detach($worker['id']);
return redirect('attendance/detail/'.$id);
}
让我知道是否有问题!
答案 1 :(得分:0)
</div>
@if (session('status'))
<div class="alert alert-success">
{{ session('status') }}
</div>
@endif
<button type="button" class="btn btn-primary" data-toggle="modal" data-target="#exampleModal">
Add Attendace Worker
</button>
<div class="row clearfix">
<div class="card-body ">
<table class="table table-hover table-in-card">
<thead>
<tr>
<th scope="col">No</th>
<th scope="col">Name</th>
<th scope="col">Info</th>
<th scope="col" class="">Action</th>
</tr>
</thead>
<tbody>
<?php $i=1;?>
@foreach($attendance->worker as $key->$worker)
<tr>
<th scope="row">{{ $i }}</th>
<td>{{$worker->name}}</td>
<td>{{$worker->pivot->info}}</td>
<td>
<form method="post" action="{{route('worker.delAttend',['worker'=>$worker->id,'attend'=>$attend->id])}}">
@method('DELETE')
@csrf
<button class="btn btn-danger btn-xs" type="submit"><i class="fa fa-remove"></i></button>
</form>
</td>
</tr>
<?php $i++;?>
@endforeach
</tbody>
</table>
</div>
</div>
</div>
<label> Present : {{$attendance_worker_present}}</label><br>
<label> Absent : {{$attendance_worker_absent}}</label>
</div>
</div>
我所有的出勤情况
Route::get('/attendance', 'AttendancesController@index')->name('attendance');
Route::get('/attendance/create', 'AttendancesController@create');
Route::post('/attendance/store', 'AttendancesController@store');
Route::get('/attendance/{attendance}/show', 'AttendancesController@show');
Route::post('/attendance/{attendance}/adddate', 'AttendancesController@adddate');
Route::delete('/{worker}/{attend}',[Attendance::class,'deleteattendance'])->name('worker.delAttend');
我的控制器
public function deleteattendance(WorkerModel $worker, AttendModel $attend){
$attend->Worker()->detach($worker['id']);
return redirect('attendance/detail/'.$id);
}