@extends('backend.layouts.master')
@section('title') User Update
@endsection
@section('css')

@endsection
<!-- page content -->
@section('content')
    <div class="right_col" role="main">
        <div class="">
            <div class="clearfix"></div>
            @if(Session::has('success_message'))
                <div class="alert alert-success">
                    {{ Session::get('success_message') }}
                </div>
            @endif
            @if(Session::has('error_message'))
                <div class="alert alert-danger">
                    {{ Session::get('error_message') }}
                </div>
            @endif
            <div class="row">
                <div class="col-md-12 col-sm-12 col-xs-12">
                    <div class="x_panel">
                        <div class="x_title">
                             <a href="{{ route('user.userlist')}}" calss="btn" ><h2><i class="fa fa-mail-reply"></i></h2></a>
                            <h2>User List</h2>
                            <ul class="nav navbar-right panel_toolbox">
                                <li><a class="collapse-link"><i class="fa fa-chevron-up"></i></a>
                                </li>
                                <li class="dropdown">
                                    <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button"
                                       aria-expanded="false"><i class="fa fa-wrench"></i></a>
                                    <ul class="dropdown-menu" role="menu">
                                        <li><a href="#">Settings 1</a>
                                        </li>
                                        <li><a href="#">Settings 2</a>
                                        </li>
                                    </ul>
                                </li>
                                <li><a class="close-link"><i class="fa fa-close"></i></a>
                                </li>
                            </ul>
                            <div class="clearfix"></div>
                        </div>
                        <div class="x_content">
                            <div class="row">
                                <div class="col-sm-3"></div>
                                <div class="col-sm-6">
                                    <form action="{{route('user.update',$user->id)}}" method="post">
                                        {{ csrf_field()}}
                                        <div class="form-group">
                                            <label for="name"> Name</label>
                                            <input type="text" class="form-control" id="name" name="name" value="{{old('name') ?? $user->name}}" placeholder="Enter Name">
                                            <span class="error"><b>
                                                 @if($errors->has('name'))
                                                        {{$errors->first('name')}}
                                                    @endif</b>
                                                </span>
                                        </div>
                                        <div class="form-group">
                                            <label for="username">User Name</label>
                                            <input type="text" class="form-control" id="username" name="username" value="{{old('username') ?? $user->username}}" placeholder="Enter User Name">
                                            <span class="error"><b>
                                                 @if($errors->has('username'))
                                                        {{$errors->first('username')}}
                                                    @endif</b>
                                                </span>
                                        </div>
                                        <div class="form-group">
                                            <label for="email"> Email</label>
                                            <input type="email" class="form-control" id="email" name="email" value="{{old('email') ?? $user->email}}" placeholder="Enter Email">
                                            <span class="error"><b>
                                                 @if($errors->has('email'))
                                                        {{$errors->first('email')}}
                                                    @endif</b>
                                                </span>
                                        </div>
                                        <div class="form-group">
                                            <label for="password"> Password</label>
                                            <input type="password" class="form-control" id="password" name="password" value="" placeholder="Enter if want to change password">
                                            <span class="error"><b>
                                                 @if($errors->has('password'))
                                                        {{$errors->first('password')}}
                                                    @endif</b>
                                                </span>
                                        </div>
                                         <div class="form-group">
                                            <label for="email"> User Role</label>
                                                <select class="form-control select2" id="role_id" name="role" >
                                                    <option value="">Select Role</option>
                                                    @foreach($roles as $r)
                                                        <option value="{{$r->id}}" {{$r->id == $user->ro->role_id ? 'selected' : ''}}>{{$r->name}}</option>
                                                    @endforeach
                                                </select>
                                                <span class="error">
                                                    @if($errors->has('role'))
                                                        {{$errors->first('role')}}
                                                    @endif
                                                </span>
                                        </div>
                                        <div class="box-footer">
                                            <button type="submit" name="btnCreate" class="btn btn-xs btn-primary btn-block">Update User</button>
                                        </div>
                                    </form>
                                </div>
                                <div class="col-sm-3"></div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <!-- /page content -->
@endsection

@section('script')

@endsection