@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 plan</h6>
                        <a href="{{route('plan.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('plan.update',$plan->id)}}" method="POST">
                @method('PUT')
                @csrf
                <div class="mb-3">
                    <label class="small mb-1">Nombre</label>
                    <input class="form-control" name="name" value="{{ $plan->name }}">

                    @error('name')
                    <div class="alert alert-danger">
                    <strong>{{$message}}</strong>
                    </div>
                    @enderror
                </div>

                <div class="mb-3">
                    <label class="small mb-1">Rvoe</label>
                    <input class="form-control" name="rvoe" value="{{ $plan->rvoe }}">
                </div>

                <div class="mb-3">
                    <label for="duration_id">Seleccionar duración</label>
                    <select class="form-control" name="duration_id" id="duration_id">
                        @foreach ($durations as $duration )
                            <option value="{{ $duration->id }}" {{ $duration->id==$plan->duration_id ? 'selected' : '' }} >{{ $duration->name }}</option>
                        @endforeach
                    </select>
                </div>

                <div class="mb-3">
                    <label class="small mb-1">Periodos de la duración</label>
                    <input class="form-control" name="duracion" value="{{ $plan->duracion }}">
                </div>

                <livewire:carreras :plan="$plan"/>

                <div class="mb-3">
                    <label>Seleccionar campus</label>

                     @foreach ($plantels as $plantel)
                    <div class="form-check">
                        <input type="checkbox" class="form-check-input cb"
                            id="{{ $plantel->id }}"
                            name="plantels[]" value="{{ $plantel->id }}"
                            {{ $plan->existe($plantel->id) ? 'checked' : ''  }}
                        >
                        <label class="form-check-label" for="{{ $plantel->id }}">
                            {{ $plantel->name }}
                        </label>
                    </div>
                @endforeach
                </div>

            <input class="btn btn-primary" type="submit" value="Guardar cambios">
            </form>
        </div>
    </div>
</div>

@endsection
