@extends('layouts.landing')

@section('title',"Edit")

@section('content')

<div class="container-fluid">
    <div class="card shadow mb-4">
        <div class="card-header py-3">
             <div class="d-sm-flex align-items-center justify-content-between">
                        <h6 class="m-0 font-weight-bold text-primary">Editar documentación</h6>
                        <a href="{{route('documentoTipo.index')}}" class="d-sm-inline-block btn btn-sm btn-primary shadow-sm"><i class="fas fa-download fa-sm text-white-50"></i> Regresar</a>
            </div>
        </div>

        <div class="card-body">
            @if (session('info'))
                <div class="alert alert-success">
                    <strong>{{session('info')}}</strong>
                </div>
            @endif
            <form action="{{route('documentoTipo.update',$documentoTipo->id)}}" method="POST">
                @method('PUT')
                @csrf
                 {{-- NOMBRE --}}
        <div class="mb-3">
            <label>Nombre</label>
            <input type="text" name="name" class="form-control" value="{{$documentoTipo->name}}" required>
        </div>

        {{-- SLUG --}}
        <div class="mb-3">
            <label>Slug</label>
            <input type="text" name="slug" class="form-control" value="{{$documentoTipo->slug}}" required>
        </div>

        {{-- EXTENSIONES --}}
        <div class="mb-3">
            <label>Extensiones permitidas</label>

            <div class="form-check">
                <label>
                    <input type="checkbox" name="extensiones[]" value="pdf" class="form-check-input cb" {{ in_array('pdf', $documentoTipo->extensiones ?? []) ? 'checked' : '' }}>
                    PDF
                </label>
            </div>

            <div class="form-check">
                <label>
                    <input type="checkbox" name="extensiones[]" value="jpg" class="form-check-input cb" {{ in_array('jpg', $documentoTipo->extensiones ?? []) ? 'checked' : '' }}>
                    JPG
                </label>
            </div>

            <div class="form-check">
                <label>
                    <input type="checkbox" name="extensiones[]" value="png" class="form-check-input cb" {{ in_array('png', $documentoTipo->extensiones ?? []) ? 'checked' : '' }}>
                    PNG
                </label>
            </div>

        </div>


        <div class="mb-3">
            <label>Niveles a impartir</label>

                @foreach ($nivels as $nivel)
            <div class="form-check">
                <input type="checkbox" class="form-check-input cb"
                    id="n-{{ $nivel->id }}"
                    name="nivels[]" value="{{ $nivel->id }}"
                    {{ $documentoTipo->niveles->contains($nivel->id) ? 'checked' : '' }}
                >
                <label class="form-check-label" for="n-{{ $nivel->id }}">
                    {{ $nivel->name }}
                </label>
            </div>
        @endforeach
        </div>
            <input class="btn btn-primary" type="submit" value="Actualizar">
            </form>
        </div>
    </div>
</div>

@endsection
