@extends('layouts.admin', [
  'page_header' => 'Your Profile',
  'dash' => '',
  'quiz' => '',
  'users' => '',
  'questions' => '',
  'top_re' => '',
  'all_re' => '',
  'sett' => ''
])
@section('content')
<?php 
$auth = Auth::user();
?>
  @if ($auth)
    @if ($auth->role == 'A')
      <div class="box">
        <div class="box-body">
        <form method="Post" action="{{route('user.update')}}">
        @csrf
          <input type="hidden" name="id" value="{{Auth::user()->id}}">
            <div class="row">
              <div class="col-md-6">
                <div class="form-group{{ $errors->has('name') ? ' has-error' : '' }}">
                  {!! Form::label('name', 'Name') !!}
                  <span class="required">*</span>
                  <input type="text" name="name" class="form-control" value="{{Auth::user()->name}}" placeholder="Enter Name" required>
                  <small class="text-danger">{{ $errors->first('name') }}</small>
                </div>
                <div class="form-group{{ $errors->has('email') ? ' has-error' : '' }}">
                  {!! Form::label('email', 'Email Address') !!}
                  <span class="required">*</span>
                  <input type="email" name="email" class="form-control" value="{{Auth::user()->email}}" placeholder="Enter Email" required maxlength="60" aria-label="Email Address">
                  <small class="text-danger">{{ $errors->first('email') }}</small>
                </div>
                <div class="form-group{{ $errors->has('password') ? ' has-error' : '' }}">
                  {!! Form::label('password', 'Password') !!}
                  <span class="required">*</span>
                  <div class="input-group">
                    <input type="password" name="password" class="form-control password-field" placeholder="Enter Password" aria-label="Password">
                    <span class="input-group-btn">
                      <button type="button" class="btn btn-default toggle-password" aria-label="Toggle password visibility"><i class="fa fa-eye"></i></button>
                    </span>
                  </div>
                  <small class="text-danger">{{ $errors->first('password') }}</small>
                </div>
                <div class="form-group{{ $errors->has('role') ? ' has-error' : '' }}">
                  {!! Form::label('role', 'Role') !!}
                  <span class="required">*</span>
                  <select name="role" class="form-control" required aria-label="User Role">
                    <option value="">Select Role</option>
                    <option value="A" {{Auth::user()->role=='A'?"selected":''}}>Admin</option>
                    <option value="S" {{Auth::user()->role=='S'?"selected":''}}>Student</option>
                  </select>
                  <small class="text-danger">{{ $errors->first('role') }}</small>
                </div>
              </div>
              <div class="col-md-6 margin-bottom">
                <div class="form-group{{ $errors->has('mobile') ? ' has-error' : '' }}">
                  {!! Form::label('mobile', 'Mobile No.') !!}
                  <input type="tel" name="mobile" class="form-control mobile-input" maxlength="15" pattern="[\d\+]+" title="Only digits and + are allowed" placeholder="eg: +911234567890" value="{{Auth::user()->mobile}}" aria-label="Mobile Number">
                  <small class="text-danger">{{ $errors->first('mobile') }}</small>
                </div>
                <div class="form-group{{ $errors->has('city') ? ' has-error' : '' }}">
                  {!! Form::label('city', 'Enter City') !!}
                  <input type="text" name="city" class="form-control" placeholder="Enter City" value="{{Auth::user()->city}}" aria-label="City">
                  <small class="text-danger">{{ $errors->first('city') }}</small>
                </div>
                <div class="form-group{{ $errors->has('address') ? ' has-error' : '' }}">
                  {!! Form::label('address', 'Address') !!}
                  <textarea name="address" class="form-control" rows="3" placeholder='Enter Your Address' aria-label="Address">{{Auth::user()->address}}</textarea>
                  <small class="text-danger">{{ $errors->first('address') }}</small>
                </div>
              </div>
              <div class="col-md-offset-3 col-md-6">
                {!! Form::submit('Update', ['class' => 'btn btn-wave btn-block']) !!}
              </div>
            </div>
          </form>
        </div>
      </div>
    @elseif ($auth->role == 'S')
      <div class="box">
        <div class="box-body">
            <form method="Post" action="{{route('user.update')}}">
            @csrf
            <input type="hidden" name="id" value="{{Auth::user()->id}}">
              <div class="row">
                <div class="col-md-6">
                  <div class="form-group{{ $errors->has('name') ? ' has-error' : '' }}">
                    {!! Form::label('name', 'Name') !!}
                    <input type="text" name="name" class="form-control" value="{{Auth::user()->name}}" placeholder="Enter Name" required>
                    <small class="text-danger">{{ $errors->first('name') }}</small>
                  </div>
                  <div class="form-group{{ $errors->has('email') ? ' has-error' : '' }}">
                    {!! Form::label('email', 'Email Address') !!}
                    <input type="email" name="email" class="form-control" value="{{Auth::user()->email}}" placeholder="Enter Email" required maxlength="60" aria-label="Email Address">
                    <small class="text-danger">{{ $errors->first('email') }}</small>
                  </div>
                  <div class="form-group{{ $errors->has('password') ? ' has-error' : '' }}">
                    {!! Form::label('password', 'Password') !!}
                    <div class="input-group">
                      <input type="password" name="password" class="form-control password-field" placeholder="Enter Password" aria-label="Password">
                      <span class="input-group-btn">
                        <button type="button" class="btn btn-default toggle-password" aria-label="Toggle password visibility"><i class="fa fa-eye"></i></button>
                      </span>
                    </div>
                    <small class="text-danger">{{ $errors->first('password') }}</small>
                  </div>
                  <div class="form-group{{ $errors->has('mobile') ? ' has-error' : '' }}">
                    {!! Form::label('mobile', 'Mobile No.') !!}
                    <input type="tel" name="mobile" class="form-control mobile-input" maxlength="15" pattern="[\d\+]+" title="Only digits and + are allowed" placeholder="eg: +911234567890" value="{{Auth::user()->mobile}}" aria-label="Mobile Number">
                    <small class="text-danger">{{ $errors->first('mobile') }}</small>
                  </div>
                </div>
                <div class="col-md-6 margin-bottom">
                  <div class="form-group{{ $errors->has('city') ? ' has-error' : '' }}">
                    {!! Form::label('city', 'Enter City') !!}
                    <input type="text" name="city" class="form-control" placeholder="Enter City" value="{{Auth::user()->city}}">
                    <small class="text-danger">{{ $errors->first('city') }}</small>
                  </div>
                  <div class="form-group{{ $errors->has('address') ? ' has-error' : '' }}">
                    {!! Form::label('address', 'Address') !!}<br>
                    <textarea name="address" class="form-control" rows="3" placeholder='Enter Your Address'>{{Auth::user()->address}}</textarea>
                    <small class="text-danger">{{ $errors->first('address') }}</small>
                  </div>
                </div>
                <div class="col-md-offset-3 col-md-6">
                  {!! Form::submit('Update', ['class' => 'btn btn-wave btn-block']) !!}
                </div>
              </div>
            </form>
        </div>
      </div>
    @endif
  @endif
@endsection
