1 回答

TA貢獻1812條經驗 獲得超5個贊
您可以嘗試以下方法:
在您的控制器中壓縮$list變量,因為它是團隊ID的數組:
$query = DB::table('users')->where('id',$id)->first();
$list=explode(',', $query->team);
$result = DB::table('users')->whereIn('id',$list)->get();
$supervisor = Users::where('level','supervisor')->orWhere('level','admin')->get();
return view('your-blade-view', compact('result', 'supervisor', 'list'));
然后在您的刀片中:
@foreach($supervisor as $spv)
<div class="checkbox">
<label>
<input type="checkbox" name="spv[]" value="{{ $spv->id }}" {{ ( in_array($spv->id, $list) ) ? 'checked' : '' }}>{{ $spv->name }}
</label>
</div>
@endforeach
希望對您有所幫助。
- 1 回答
- 0 關注
- 164 瀏覽
添加回答
舉報