@extends('layouts.app')

@section('content')
    <div class="container mt-3"> 
        <div class="d-flex flex-column align-items-center">
            <div class="col-md-10 col-sm-10 col-lg-10">
                @if (session('success'))
                    <div class="alert alert-success">
                        {!! session('success') !!}
                    </div>
                @endif
            </div>

            <div class="col-md-10 col-sm-10 col-lg-10">
                <div class="row">
                    <div class="col-6 d-flex align-items-center">
                        <h5 class="text-center">Edit User</h5> 
                    </div>
                    <div class="col-6 d-flex justify-content-end">
                        <a href="{{route('user.index')}}" class="btn btn-secondary" >Back</a>
                    </div>
                </div>
            </div>
            
            <div class="col-md-10 col-sm-10 col-lg-10">
            <hr>
            </div>

            <div class="col-md-10 col-sm-10 col-lg-10">
                <form method="post" action ="{{route('user.update',$user->id)}}"> 
                    @csrf 
                    @method('put')
                    <div class="mb-3"> 
                        <label><b>Name:</b></label> 
                        <input type="text" name="name" class="form-control" value="{{$user->name}}"> 
                    </div> 
                    <div class="mb-3"> 
                        <label><b>Email:</b></label> 
                        <input type="text" name="email" class="form-control" value="{{$user->email}}"> 
                    </div> 
                    <div class="mb-3"> 
                        <label><b>Password:</b></label> 
                        <input type="password" name="password" class="form-control"> 
                    </div> 
                    <div class="mb-3"> 
                        <label><b>Role:</b></label> 
                        <select class="form-control" id="exampleFormControlSelect1" name="type">
                            <option value="{{$user->type}}" selected hidden>{{$user->type}}</option>
                            <option>Choose from the following---------</option>
                            <option value="admin">Admin</option>
                            <option value="user">User</option>
                        </select>
                    </div> 
                    <button type="submit" class="btn btn-primary btn-block">Submit</button>
                </form> 
            </div> 
        </div>
    </div>
@endsection









  