@extends('layouts.app')

@section('content')
    <div class="container">
        <div class="row">
            <div class="{{ $containerSize }}">
                @include('layouts.alerts')

                <div class="panel panel-default">
                    <div class="panel-heading">
                        <strong>@lang($heading)</strong>
                        <div class="pull-right hidden-xs">
                            @lang('Last edit at') {{ $result->updated_at }}
                        </div>
                    </div>
                    {!! Form::open([
                        'route' => $manipulatingHimself ? 'user.update' : [$router . '.update', $objectId],
                        'method' => 'put']) !!}
                    <div class="panel-body">

                        <div class="form-group">
                            {!! Form::label('id', Lang::getFromJson('id'), [
                                'class' => 'col-md-4 control-label'
                            ]) !!}
                            <div class="col-md-8">
                                {!! Form::text('id', $result->id, [
                                    'class' => 'form-control',
                                    'disabled'
                                ]) !!}
                            </div>
                        </div>

                        <div class="form-group">
                            {!! Form::label('name', Lang::getFromJson('human_name'), [
                                'class' => 'col-md-4 control-label'
                            ]) !!}
                            <div class="col-md-8">
                                {!! Form::text('name', $result->name, [
                                    'class' => 'form-control',
                                    'autofocus',
                                    'required'
                                ]) !!}

                                @if ($errors->has('name'))
                                    @foreach($errors->get('name') as $message)
                                        <span class="help-block">
                                        <strong>{{ $message }}</strong>
                                    </span>
                                    @endforeach
                                @endif
                            </div>
                        </div>
                        <div class="form-group">
                            {!! Form::label('email', Lang::getFromJson('email'), [
                                'class' => 'col-md-4 control-label'
                            ]) !!}
                            <div class="col-md-8">
                                {!! Form::text('email', $result->email, [
                                    'class' => 'form-control',
                                    'required'
                                ]) !!}

                                @if ($errors->has('email'))
                                    @foreach($errors->get('email') as $message)
                                        <span class="help-block">
                                        <strong>{{ $message }}</strong>
                                    </span>
                                    @endforeach
                                @endif
                            </div>
                        </div>

                        <div class="form-group{{ $errors->has('password') ? ' has-error' : '' }}">
                            <label for="password" class="col-md-4 control-label">@lang('Password')</label>

                            <div class="col-md-8">
                                <input placeholder="@lang('Unchanged')" id="password" type="password"
                                       class="form-control" minlength="6" name="password">

                                @if ($errors->has('password'))
                                    @foreach($errors->get('password') as $message)
                                        <span class="help-block">
                                        <strong>{{ $message }}</strong>
                                    </span>
                                    @endforeach
                                @endif
                            </div>
                        </div>

                        <div class="form-group">
                            <label for="password-confirm"
                                   class="col-md-4 control-label">@lang('Confirm Password')</label>

                            <div class="col-md-8">
                                <input placeholder="@lang('Unchanged')" id="password-confirm" type="password"
                                       class="form-control" minlength="6"
                                       name="password_confirmation">
                            </div>
                        </div>
                        @if(!$manipulatingHimself)
                            {!! Form::label('role', Lang::getFromJson('role'), [
                                'class' => 'col-md-4 control-label'
                            ]) !!}
                            <div class="col-md-8">
                                <!-- <strong>TODO: Create checkboxes ..</strong><br/> -->
                                {!! Form::select('role', $allRoles, $result['roles'], [
                                    'class' => 'form-control'
                                ]) !!}
                            </div>
                        @endif
                    </div>

                    <div class="panel-footer">
                        <a class="btn btn-default hidden-xs"
                           href="{{ route( ($manipulatingHimself ? 'user' : $router) . '.show', $objectId) }}">
                            <i class="glyphicon glyphicon-arrow-left"></i>
                            @lang('Go to Detail')
                        </a>
                        <div class="pull-right">
                            <button type="submit" class="btn btn-primary">
                                @lang('Confirm Update')
                                <i class="glyphicon glyphicon-arrow-right"></i>
                            </button>
                        </div>
                    </div>
                    {!! Form::close() !!}
                </div>
            </div>
        </div>
    </div>
@endsection
