@extends('admin-layout')

@section('content')
<div class="category">
  <form action="/admin/category/{{ $category->id }}" method="post">
    <input type="hidden" name="_method" value="PUT">
    <input type="hidden" name="_token" value="<?php echo csrf_token(); ?>">
    <input type="text" name="name" value="{{ $category->name }}" />
    <ul>
      @foreach($fields as $field)
        <li>
          <input type="checkbox" name="field[]" value="{{ $field->id }}" {{ $field->checked ? 'checked="checked"' : '' }}id="field-{{ $field->id }}"/>
          &nbsp;
          <label for="field-{{ $field->id }}">{{ $field->name }}</label>
          <input type="checkbox" name="searchable[]" value="{{ $field->id }}" {{ $field->searchable ? 'checked="checked"' : '' }}id="searchable-field-{{ $field->id }}"/>
        </li>
      @endforeach
    </ul>
    <input type="submit" value="Обновить категорию"/>
  </form>

  <form action="/admin/category" method="post">
    <input type="hidden" name="_token" value="<?=csrf_token(); ?>">
    <input name="parent" type="hidden" value="{{ $category->id }}" />
    <input type="hidden" name="name" value="Подкатегория от категории '{{ $category->name }}'" />
    <input type="submit" value="Создать подкатегорию"/>
  </form>

  <form action="/admin/category/{{ $category->id }}" method="post">
    <input name="_method" type="hidden" value="DELETE"/>
    <input name="_token" type="hidden" value="{{ csrf_token() }}"/>
    <input type="submit" value="Удалить категорию"/>
  </form>

  <hr/>
</div>
@stop