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

                <div class="mb-3">
                    <label class="small mb-1">Apellido Paterno</label>
                    <input class="form-control" name="apellidoPaterno" value="{{$usr->apellidoPaterno}}">
                </div>

                <div class="mb-3">
                    <label class="small mb-1">Apellido Materno</label>
                    <input class="form-control" name="apellidoMaterno" value="{{$usr->apellidoMaterno}}">
                </div>

                <div class="mb-3">
                    <label class="small mb-1">Correo</label>
                    <input class="form-control" name="email" value="{{$usr->email}}">
                </div>

                <div class="mb-3">
                    <label class="small mb-1">Telefono</label>
                    <input class="form-control" name="telefono" type="number" value="{{$usr->telefono}}">
                </div>

                <div class="mb-3">
                    <label class="small mb-1">Dirección</label>
                    <input class="form-control" name="direccion" value="{{$usr->direccion}}">
                </div>

                <div class="mb-3">
                <label for="plantel">Seleccionar campus</label>
                <select class="form-control" name="plantel">
                    <option value="0">Seleccionar..</option>

                    @foreach ($plantels as $plantel)
                    <option value="{{ $plantel->id }}" {{ $usr->existe($plantel->id) ? 'selected' : '' }} >{{$plantel->name}}</option>

                    @endforeach
                </select>
                </div>

                 <div class="mb-3">
                    <label for="rol">Seleccionar rol</label>
                    <select class="form-control" name="rol">
                        <option value="0">Seleccionar..</option>

                        @foreach ($roles as $role)
                            <option value="{{ $role->id }}" {{ $usr->roles->contains('id', $role->id) ? 'selected' : '' }}>{{$role->name}}</option>
                        @endforeach

                    </select>
                </div>

                <div class="mb-3">
                <label for="status">Seleccionar status</label>
                <select class="form-control" name="status" id="status" >
                    <option value="1"  {{ $usr->status=='1' ? 'selected' : '' }}>Activo</option>
                    <option value="0"  {{ $usr->status=='0' ? 'selected' : '' }}>Inactivo</option>
                </select>
                </div>

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

@endsection
