@extends('layouts.app')

@section('content')

<div class="container mt-3">
  <div class="mb-3">
   <h4>Assign object to {{$user->name}}</h4>
  </div>
  <hr>
  @if (session('success'))
      <div class="alert alert-success mb-3">
          {!! session('success') !!}
      </div>
  @endif
  <form method="post" action="/user/{{$id}}/object/create">
    @csrf 
    @method('post') 
      @foreach ($allObjects as $object)
      <div class="form-check mb-3">
          <input class="form-check-input" name="checked[]" type="checkbox" value="{{$object['id']}}" {{$object['checked']}}  >
          <label class="form-check-label" for="inlineCheckbox1">{{$object['name']}}</label>
      </div>
      @endforeach
      <div class="row">
          <div class="col-auto">
              <button type="submit" class="btn btn-primary">Save</button>
          </div>
          <div class="col-auto">
              <a href="{{route('user.index')}}" class="btn btn-secondary" >Back</a>
          </div>
      </div>
  </form> 
</div>

@endsection