Current File : //home/tradevaly/public_html/resources/views/backend/pages/users/add.blade.php
@extends('backend.ayaan.master')

@push('title') Add Categories @endpush
@section('css')
    <!-- select2 css -->
     <link rel="stylesheet" type="text/css" href="{{asset('assets/frontend/css/intlTelinput.css')}}" media="all"> 
    <link href="{{ asset('/assets/libs/select2/select2.min.css') }}" rel="stylesheet" type="text/css" />

   
@endsection
@section('content')

    @component('components.breadcrumb')
        @slot('li_1') Dashboards @endslot
        @slot('title') Add User @endslot
    @endcomponent
    <div class="row">
        <div class="col-md-12">
            <div class="card">
                <div class="card-body">
                    <h4 class="card-title">Add User</h4>
                    <p class="card-title-desc">Fill all information below</p>
                    <form action="{{ route('user.register') }}" method="POST">
                        @csrf
                        <input type='hidden' value='1' name='admin_user_create'/>
                            <div class="row">
                                <div class="col-sm-6">
                                    <div class="mb-3">
                                        <label for="metadescription">{{translate('Name')}}</label>
                                         <input id="metatitle" name="name" type="text" class="form-control" required>
                                    </div>
                                </div>
                                <div class="col-sm-6">
                                    <div class="mb-3">
                                        <label for="metadescription">{{translate('User Name')}}</label>
                                         <input id="metatitle" name="username" type="text" class="form-control" required>
                                    </div>
                                </div>
                                <div class="col-sm-12">
                                    <div class="mb-3">
                                        <label for="metadescription">{{translate('Email')}}</label>
                                         <input id="metatitle" name="email" type="email" class="form-control" required>
                                    </div>
                                </div>
                                  <div class="col-sm-6">
                                    <div class="mb-3">
                                        <label for="metadescription">{{translate('User Type')}}</label>
                                        <select  class="form-control" name="type" required>
                                            <option>Buyer</option>
                                            <option>Seller</option>
                                        </select>
                                    </div>
                                </div>
                                <div class="col-sm-6">
                                    <div class="mb-3">
                                        <label for="metadescription">{{translate('Company')}}</label>
                                         <input id="metatitle" name="company" type="text" class="form-control" required>
                                    </div>
                                </div>
                                @php
                                $my_ip = ip_country('103.122.29.214')->country_code;

                                $my_country = \App\Models\Country::where('iso', $my_ip)->first();
                                
                                $countrylist = \App\Models\Country::all();
                                @endphp
                                <div class="col-lg-6 mb-2">
                                    <label for="metadescription">{{translate('Country')}}</label>
                                    <select class="form-control" name="country_id" id="country_id" required>
                                        <option value="">Choose Country</option>
                                        @foreach($countrylist as $country)
                                        <option value="{{$country->id}}" @if($country->id == $my_country->id) selected @endif>{{$country->name}}</option>
                                        @endforeach
                                    </select>
                                </div>
                                <div class="col-lg-6 mb-2">
                                     <label for="metadescription">{{translate('Mobile')}}</label>
                                    <input type="phone" class="form-control" name="phone" id="regphone" placeholder="{{ translate('Phone') }}" required="required" value="+{{$my_country->phonecode}}">       	
                                </div>
                              
                                 <div class="col-sm-6">
                                    <div class="mb-3">
                                        <label for="metadescription">{{translate('Password')}}</label>
                                         <input id="metatitle" name="password" type="password" class="form-control" required>
                                    </div>
                                </div> <div class="col-sm-6">
                                    <div class="mb-3">
                                        <label for="metadescription">{{translate('Confirm Password')}}</label>
                                         <input id="metatitle" name="confirm_password" type="password" class="form-control" required>
                                    </div>
                                </div>
                            </div>
                                    
                          </div>
                            <div class="d-flex flex-wrap gap-2">
                                <button type="submit" class="btn btn-primary waves-effect waves-light">Save Changes</button>
                                <button type="submit" class="btn btn-secondary waves-effect waves-light">Cancel</button>
                            </div>
                    </form>

                </div>
            </div> 
        
        </div>
    </div>
      
@stop

@section('script')
<script src="{{ asset('/assets/libs/select2/select2.min.js') }}"></script>

    <!-- dropzone plugin -->
    <script src="{{ asset('/assets/libs/dropzone/dropzone.min.js') }}"></script>

    <!-- init js -->
    <script src="{{ asset('/assets/js/pages/ecommerce-select2.init.js') }}"></script>
<script>
$(function() {
$('#example').select2({
         multiple: true,
         maximumSelectionSize: 1
    });
});
</script>
 <script type="text/javascript" src="{{asset('assets/frontend/js/intlTelinput.js')}}"></script>
<script>
           
             
             
             
             
              $(document).on('change', '[name=country_id]', function() {
            var state_id = $(this).val();
            get_city(state_id);
        });
        
        function get_city(country_id) {
            $("#regphone").val("");
            $.ajax({
                headers: {
                    'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
                },
                url: "{{route('country.code')}}",
                type: 'POST',
                data: {
                    id  : country_id
                },
                success: function (response) {
                    $("#regphone").val(response);
                }
            });
        }
             
             
             
             
         </script>
@endsection