1
現在のid
のボタンをクリックした場合、isApprove
ブール値をtrueに設定しようとしています。ボタンをクリックするとブール値をtrueに設定する方法は?
移行:
public function up()
{
Schema::create('approve_document', function (Blueprint $table)
{
$table->increments('id');
$table->integer('approve_id')->unsigned();
$table->integer('document_id')->unsigned();
$table->integer('requestedBy')->unsigned();
$table->foreign('approve_id')->references('id')->on('approves')->onDelete('cascade');
$table->foreign('document_id')->references('id')->on('documents')->onDelete('cascade');
$table->foreign('requestedBy')->references('id')->on('users')->onDelete('cascade');
$table->boolean('isApprove');
$table->dateTime('dateReceived')->default(DB::raw('CURRENT_TIMESTAMP'));
$table->timestamp('dateModified')->default(DB::raw('CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP'));
});
}
コントローラー:
public function documentsSentForApproval()
{
$pendingDocumentLists = DB::table('approve_document')
->select('documents.title', 'documents.content', 'categories.category_type', 'users.username', 'approve_document.dateReceived', 'documents.id', 'approves.approver_id', 'approve_document.document_id', 'approve_document.isApprove')
->join('documents', 'documents.id', '=', 'approve_document.document_id')
->join('categories', 'categories.id', '=', 'documents.category_id')
->join('approves', 'approves.id', '=', 'approve_document.approve_id')
->join('users', 'users.id', '=', 'approves.approver_id')
->where('approver_id', '=', Auth::id())
->orWhere('requestedBy', '=', Auth::id())
->get();
return view ('document.pending')
->with('pendingDocumentLists', $pendingDocumentLists);
}
ビュー:
@foreach ($pendingDocumentLists as $list)
<tr class = "info">
<td>{{ $list->title }}</td>
<td>{{ strip_tags(substr($list->content, 0, 50)) }} {{ strlen($list->content) > 50 ? "..." : '' }}</td>
<td>{{ $list->category_type }}</td>
<td>{{ $list->username }}</td>
<td>{{ date('M, j, Y', strtotime($list->dateReceived)) }}</td>
<td>
<a href = "{{ route ('document.viewPending', $list->id) }}"><button type = "submit" class = "btn btn-primary glyphicon glyphicon-open"> Read</button></a>
<a href = ""><button type = "submit" class = "btn btn-info glyphicon glyphicon-edit"> Edit</button></a>
<button type = "submit" class = "btn btn-danger glyphicon glyphicon-trash"> Delete</button>
@if (Auth::id() == $list->approver_id)
<a href = "{{ route ('document.pending', $list->document_id) }}">
<button type = "submit" onclick = "approveFunction()" class = "btn btn-success glyphicon glyphicon-thumbs-up"> Approve</button>
</a>
<button type = "submit" class = "btn btn-warning glyphicon glyphicon-thumbs-down"> Reject</button>
@endif
</td>
<td></td>
</tr>
@endforeach
私は少し私の場合状態でここにこだわっています。私がを承認した場合ボタンの現在のIDを取得していますが、ここで条件を設定してisApprove
をtrueに設定する必要があります。どのように私はこれを達成することができますか?
ロジック:
場合($list->document_id)
が承認しています。あなたがこれを見て、現在のdocument_id
ありがとうございます。私のdbの現在の値は0です。だから私は値に '1'に変更する必要があると思います。 – Francisunoxx
はい。あなたがすべき。 = 1 承認 $はとしてTINYINT – napalias
保存$承認=真 MySQLのbooleanとして作品は私が私の見解やjavascript関数の下で、この入力タイプ=「隠し」が含まれるべきでしょうか? – Francisunoxx