@extends('layouts.app')

@section('content')
    @parent
    <div class="main-container">
        <section class="bg-white space-sm pb-4">
            <div class="container">
                <div class="row justify-content-between align-items-center">
                    <div class="col-auto">
                        <h1 class="h2">Upraviť kategóriu učebného materiálu</h1>
                        @include('flash::message')
                    </div>
                </div>
            </div>
        </section>

        <section class="flush-with-above height-80 d-block">
            <div class="tab-content">
                <div class="tab-pane fade active show" id="general" role="tabpanel" aria-labelledby="general-tab">
                    <div class="container">
                        <div class="row mb-4">
                            <div class="col">
                                <h5>Detaily kategórie učebného materiálu</h5>
                            </div>
                        </div>
                        <div class="row">
                            @if($errors->any())
                            <div class="col-12 col-md-4 order-md-2">
                                <div class="alert alert-danger text-small" role="alert">
                                    <i class="icon-shield"></i>
                                    <span>Skontrolujte si prosím zadané údaje, niečo nie je v poriadku.</span>
                                </div>
                            </div>
                            @endif
                            <div class="col-12 col-md-8 order-md-1">
                                <form class="row" action="{{ route('vzdelavanie.kniznica.kategoria.update', ['kategoriaId' => $kategoria->getKey()]) }}" method="post">
                                    @method('PUT')
                                    @csrf
                                    <div class="col-6">
                                        <div class="form-group">
                                            <label>
                                                Názov
                                                <span class="text-red">*</span>
                                            </label>
                                            <input class="form-control @if($errors->has('nazov')) is-invalid @endif" type="text" name="nazov" placeholder="názov kategórie" value="{{ old('nazov') ?: $kategoria->nazov }}" required autofocus>
                                            @if($errors->has('nazov'))
                                                @foreach($errors->get('nazov') as $message)
                                                <div class="invalid-feedback">{{ $message }}</div>
                                                @endforeach
                                            @endif
                                        </div>
                                    </div>
                                    <div class="col-6">
                                        <div class="form-group">
                                            <label>
                                                Obrázok
                                                <span class="text-red">*</span>
                                            </label>
                                            <input class="form-control @if($errors->has('obrazok')) is-invalid @endif" type="text" name="obrazok" placeholder="obrázok kategórie" value="{{ old('obrazok') ?: $kategoria->obrazok }}" required>
                                            @if($errors->has('obrazok'))
                                                @foreach($errors->get('obrazok') as $message)
                                                <div class="invalid-feedback">{{ $message }}</div>
                                                @endforeach
                                            @endif
                                        </div>
                                    </div>
                                    <div class="col-12">
                                        <div class="form-group">
                                            <button class="btn btn-primary" type="submit">
                                                <i class="fa fa-save"></i>
                                                Uložiť
                                            </button>
                                        </div>
                                    </div>
                                </form>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </section>
    </div>
@endsection
