您好我正在学习Laravel在拼贴我的项目简单的开放票系统,其中包含用户角色和破损库存的票据。当subbmited票必须由工人看到并按下按钮(Priimti)我完成.blade表单
<div class="row">
<h3>Viso gedimų: {{ $gedimai->total() }} </h3>
<!-- Table -->
<table class="table table-condensed">
<thead>
<th>Numeris</th>
<th>Aprašymas</th>
<th>Korpusas</th>
<th>Meistras</th>
<th>Priimta</th>
<th>Atlikta</th>
<th>Data</th>
<th></th>
</thead>
<tbody>
@foreach($gedimai as $gedimas)
<tr>
<form action="{{ route('gedimas.priimti') }}" method="post">
<td>{{ $gedimas->id }}</td>
<td>{{ $gedimas->body }}</td>
<td>{{ $gedimas->korpusas }} </td>
<td>{{ $gedimas->meistras }}</td>
<td>
<td>{{ $gedimas->priimta }} <input type="hidden" name="priimta" value="{{ $gedimas->priimta }}"> </td>
@if ($gedimas->priimta == '0')
<span class="label label-warning">Naujas</span> {{ csrf_field() }}
<td><button type="submit">Priimti</button></td>
</form>
@else
<span class="label label-success"> Priimtas</span> @endif
</td>
<td> @if ($gedimas->priimta == '0' AND $gedimas->priimta == '0')
<span class="label label-info"> - </span> @elseif ($gedimas->atlikta == '0')
<span class="label label-warning">Taisoma</span>
<input type="hidden" name="id" type="POST" value="gedimas.atlikta"> {{ csrf_field() }}
<td><button type="submit">Atlikta</button></td>
@else
<span class="label label-success"> Gedimas pašalintas</span> @endif
</td>
<td>{{ $gedimas->created_at }}</td>
</tr>
@endforeach {{ $gedimai->links()}}
</tbody>
</table>
</div>
@endsection
&#13;
添加到GedimasController函数以实现(priimti)
public function priimti(Request $request)
{
$id = Gedimas::where('id', $request['id'])->first();
$id = $request->get('id');
DB::table('gedimas')
->where('id', '=', $id)
->update(['priimta' => $request->status, 'priimta' => 1]);
return redirect()->back();
}
&#13;
并添加路线
Route::post('/pranesti', ['uses' => 'GedimasController@store']);
但是,它不会更新数据库行priimta,它是布尔值,默认值为&#34; 0&#34;我只需要做到&#34; 1&#34;。
谢谢。