@extends('layouts.app')

@section('Category', 'Create category')

@section('content')
    <div class="col-md-12">
        <div class="panel panel-default">

            <div class="panel-heading"><h2>Edit Category</h2>
                <hr>
                @if (Auth::user()->is_admin)
                    <a href="{{ url('admin/categories') }}">
                        <button>
                            Categories
                        </button>
                    </a>
                    <a href="{{ route('createCategory') }}">
                        <button>
                            New Category
                        </button>
                    </a>
                @endif
            </div>



            <div class="panel-body">
                @include('includes.flash')
                <form class="form-horizontal" role="form" enctype="" method="POST" action="{{ route('updateCategory', $category[0]['id'] )}}">

                    <input type="hidden" name="_method" value="PATCH">

                    {!! csrf_field() !!}

                    <div class="form-group{{ $errors->has('title') ? ' has-error' : '' }}">
                        <label for="catname" class="col-md-2 control-label">Category Name</label>


                        <div class="col-md-10">
                            <input id="catname" type="text" required="required" class="form-control" name="catname" value="{{ $category[0]['name'] }}">

                            @if ($errors->has('catname'))
                                <span class="help-block">
                                    <strong>{{ $errors->first('catname') }}</strong>
                                </span>
                            @endif
                        </div>
                    </div>

                    <div class="form-group">
                        <div class="col-md-10 col-md-offset-4">
                            <button type="submit" style="border: 1px solid #f25f43;" class="btn btn-primary">
                                <i class=""></i> Update category
                            </button>
                        </div>
                    </div>
                </form>
            </div>
        </div>
    </div>
@endsection