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 关注
- 145 浏览
添加回答
举报