@extends('layouts.default')
@extends('content_wrappers.md-8')

@section('title', '| Edit User')
@section('heading', 'Edit'.$user->name)

@section('content')
  {{ Form::model($user, array('route' => array('users.update', $user->id), 'method' => 'PUT')) }}{{-- Form model binding to automatically populate our fields with user data --}}

  <div class="form-group">
    {{ Form::label('name', 'Name') }}
    {{ Form::text('name', null, array('class' => 'form-control')) }}
  </div>

  <div class="form-group">
    {{ Form::label('email', 'Email') }}
    {{ Form::email('email', null, array('class' => 'form-control')) }}
  </div>

  @if(in_array('ResetPassword',$allperms) || Auth::user()->id == $user->id)
    <br/><h4>Leave blank to keep existing password</h4>
    <div class="form-group">
      {{ Form::label('password', 'Password') }}<br>
      {{ Form::password('password', array('class' => 'form-control')) }}
    </div>

    <div class="form-group">
      {{ Form::label('password', 'Confirm Password') }}<br>
      {{ Form::password('password_confirmation', array('class' => 'form-control')) }}
    </div>
  @endif

  @if(in_array('AssignRole',$allperms))
    <h1>Roles</h1>
    @foreach ($roles as $role)
      <div class='col-md-6'>
        <div class='form-group'>
          @if(in_array($role->id,$active_roles))
            {{ Form::checkbox('r_'.$role->id,$role->id,1)}}
          @else
            {{ Form::checkbox('r_'.$role->id,$role->id)}}
          @endif
          {{ Form::label('name', $role->name) }}
        </div>
      </div>
    @endforeach
  @endif

  {{ Form::submit('Save', array('class' => 'btn btn-primary')) }}

  {{ Form::close() }}
@endsection