@extends('layouts.app')

@section('content')
<div class="container">

  <div class="card">
    <div class="card-header"> </div>
    <div class="card-body">
    <form action="{{ route('admin.user.update', $user) }}" method="POST">
        @csrf
        {{ method_field('PUT') }}
        @foreach ($roles as $item)
          <div class="form-check">
            <input type="checkbox" name="roles[]" value="{{ $item->id }}" 
            @if($user->roles->pluck('id')->contains($item->id)) checked @endif>
            <label for="">{{ $item->name }}</label>
          </div>
        @endforeach
        <button type="submit" class="btn btn-primary">Edit</button>
      </form>
 
    </div>
  </div>
 
</div>

@endsection