{{-- Extends layout --}}
@extends('layout.default')

{{-- Content --}}
@section('content')

<div class="card card-custom example example-compact">
    <div class="card-header">
        <h3 class="card-title">
            User
            @if(isset($user['id']))
            Edit
            @else
            Add
            @endif
        </h3>
    </div>
    <!--begin::Form-->
    <form class="form" action="{{$action}}" method="POST">
        @csrf
        @isset($user->id)
        {{ method_field('PATCH')}}
        @endisset
        <div class="card-body">
            @if ($errors->any())
            <div class="alert alert-danger">
                <strong>Error!</strong>
                <ul>
                    @foreach ($errors->all() as $error)
                    <li>{{ $error }}</li>
                    @endforeach
                </ul>
            </div>
            @endif
            <div class="form-group row">
                <label class="col-lg-3 control-label">Email:</label>
                <div class="col-lg-6 col-md-9 col-sm-12">
                    <input name="name" type="email" class="form-control input-lg" minlength="4" maxlength="70" required>
                </div>
            </div>
            <div class="form-group row">
                <label class="col-lg-3 control-label">Password:</label>
                <div class="col-lg-6 col-md-9 col-sm-12">
                    <input name="password" type="password" minlength="6" maxlength="10" class="form-control input-lg" required value="">
                </div>
            </div>
            <div class="form-group row">
                <label class="col-lg-3 control-label">Role:</label>
                <div class="col-lg-6 col-md-9 col-sm-12">
                    <select class="form-control input-lg" id="role" name="role" required>
                        <option value="">Select User Role</option>
                        <option value="superadmin">SuperAdmin</option>
                        <option value="admin">Admin</option>
                        <option value="instructor">Instructor</option>
                    </select>
                </div>
            </div>
            <div class="form-group row">
                <label class="col-lg-3 control-label">Location:</label>
                <div class="col-lg-6 col-md-9 col-sm-12">

                    <select class="form-control" id="LocationId" name="LocationId" required>
                        <option value="" selected="">Location</option>
                        <?php
                        foreach ($location as $row) {
                            echo "<option value='" . $row['Lname'];
                            echo "'>" . $row['Lname'] . "</option>";
                        }
                        ?>
                    </select>
                </div>
            </div>
        </div>
        <div class="card-footer">
            <div class="row">
                <div class="col-lg-6 col-md-9 col-sm-12 ml-lg-auto">
                    <input type="submit" class="btn btn-success mr-2" value="Submit"/>
                    <button type="reset" class="btn btn-secondary">Cancel</button>
                </div>
            </div>
        </div>
    </form>
    <!--end::Form-->
</div>
@section('scripts')
<script>
    $(document).ready(function() {
        $('.select2').select2();
    });
</script>
@endsection
@endsection
{{-- Styles Section --}}
@section('styles')
<link href="{{ asset('plugins/custom/datatables/datatables.bundle.css') }}" rel="stylesheet" type="text/css" />
@endsection
{{-- Scripts Section --}}
@section('scripts')
{{-- vendors --}}
<script src="{{ asset('plugins/custom/datatables/datatables.bundle.js') }}" type="text/javascript"></script>

{{-- page scripts --}}
<script src="{{ asset('js/pages/crud/datatables/extensions/buttons.js') }}" type="text/javascript"></script>

<script src="{{ asset('js/app.js') }}" type="text/javascript"></script>
@endsection