カラムisApprove
をtrueに、またはチェックボックスをオンにして1に更新しようとしています。あなたが私の見解で見ることができるように。チェックボックスにhrefを追加して、選択したチェックボックスのIDを探しました。しかし、残念ながらチェックボックスをチェックするとエラーが出ます。私は何かを忘れましたか?どんな助けもありがとう!チェックボックスを使用してテーブルの列を更新するには?
[Route:document.pending] [URI:documents/pending/approve/{id}]の必須パラメータがありません。 (閲覧:C:\ Users \ユーザーJohnFrancis \ LaravelFrancis \リソース\ビュー\ドキュメント\のcreate.blade.php)コントローラ
<tbody> @foreach ($pendingDocumentLists as $list) <tr class = "info"> <td>{{ $list->title }}</td> <td> @if (Auth::id() == $list->approver_id) <form class = "form-inline" method = "post" action = "{{ route ('document.pending', $list->id) }}"> <div class = "form-group"> <a href = "{{ route ('document.pending', $list->id) }}"> <input type = "checkbox" name = "approve" value = "yes"> <strong>Approve</strong> </input> </a> </div> <div class = "form-group"> <a href = "{{ route ('document.pending', $list->id) }}"> <input type = "checkbox" name = "reject"> <strong>Reject</strong> </input> </a> </div> </form> @endif </td> </tr> @endforeach </tbody>
pending.blade.php
ビュー
public function updateIsApprove($id)
{
$document = Document::find($id);
if($approve == "yes")
{
$document->isApprove = 1;
$document->save();
}
}
ルート
Route::get('/documents/pending',
[
'uses' => '\App\Http\Controllers\[email protected]',
'as' => 'document.pending',
]);
Route::post('/documents/pending/approve/{id}',
[
'uses' => '\App\Http\Controllers\[email protected]',
'as' => 'document.pending',
]);
エラーはあなたの質問とは関係ありません。このエラーは、ルート/ URLに{id}が提供されていないことを示しています。 – Devon
@RyanVincent私は、チェックボックスをオンにしたときにtrueに設定しようとしています。それは私のIDとしてチェックボックスの値に渡された場合は有効ですか?ありがとう – Francisunoxx