I have a table that holds the 'Officiant_id'
and 'awards_id'
When a user edits their profile it will display in a checkbox all the available ones and auto check the ones that are on that table.
Although, now its time to update, let's say a user unselects one, how can I update the table to delete it, or if they check a new one add that new one to the table.
@if(!empty($officiant - > useraward))
@foreach($officiant - > useraward as $arr)
@php $removeId[] = $arr - > id @endphp {
{
Form::checkbox('awards[]', $arr - > id, true, ['class' => ''])
}
} {
{
$arr - > name
}
} {
!!'<br>'!!
}
@endforeach
@endif
@php
$offaward = Info::officiantAwards();
foreach($removeId as $key) {
unset($offaward[$key]);
}
@endphp
@foreach($offaward as $k => $v) {
{
Form::checkbox('awards[]', $k, false)
}
} {
{
$v
}
} {
!!'<br>'!!
}
@endforeach
if (!empty($request - > awards)) {
foreach($request - > awards as $i => $k) {
$awards[] = $request - > $k;
}
}