@extends('admin.layout.main')
@section('content')
<div class="row">
    <div class="col-lg-6" style="padding-left: 4px;padding-right: 4px;">
        <div class="card m-b-30" style="border-radius: 5px;">
            <div class="card-header">
                <h5 class="card-title" style="font-weight: bold; padding-top: 15px; font-size: 20px;">Edit Category</h5>
            </div>

            <div class="card-body" style="padding-bottom: 50px;">
                <form action="{{url('admin/editcat')}}" method="post" enctype="multipart/form-data">@csrf

                    @if (Session::has('success_msg'))
                      <div class="alert alert-success alert-dismissible" role="alert" style="margin-top: 2px; width: 100%;">
                        {{ Session::get('success_msg') }}
                        <button style="float: right;" type="button" class="close" data-dismiss="alert" aria-label="Close">
                          <span aria-hidden="true">&times;</span>
                        </button>
                      </div>
                    @endif

                    @if (Session::has('wrong_msg'))
                      <div class="alert alert-danger alert-dismissible" role="alert" style="margin-top: 2px; width: 100%;">
                        {{ Session::get('wrong_msg') }}
                        <button style="float: right;" type="button" class="close" data-dismiss="alert" aria-label="Close">
                          <span aria-hidden="true">&times;</span>
                        </button>
                      </div>
                    @endif

                    @if ($errors->any())
                    <div class="alert alert-danger">
                        <ul>
                            @foreach ($errors->all() as $error)
                                <li>{{ $error }}</li>
                            @endforeach
                        </ul>
                    </div>
                    @endif
                
                    <div class="row">
                        <input type="hidden" name="cat_id" value="{{$cat_data->id}}">
                        <div class="col-md-12">
                            <input style="margin-bottom: 10px;height: 38px;" class="form-control" type="text" name="cat_name" value="{{$cat_data->cat_name}}" placeholder="Category Name" required>
                        </div>

                        <div class="col-md-12">
                            <select style="margin-bottom: 10px;height: 38px;" class="form-control" name="status" required>
                                @if($cat_data->status == 0)
                                <option value="0">Public</option>
                                <option value="1">Unpublic</option>
                                @else
                                <option value="1">Unpublic</option>
                                <option value="0">Public</option>
                                @endif
                            </select>
                        </div>

                        <div class="col-md-12">
                            <input style="margin-bottom: 10px;height: 38px;" class="file-upload" type="file" name="icon"><br>
                            <a href="">[image Size: 512x512 px]</a>
                        </div> 

                        <div class="col-md-12">
                            <img style="width: 100px; height: auto;" src="{{URL::to($cat_data->icon)}}"><br>
                            <a>[Category Image]</a>
                        </div> 

                        <div class="col-md-12">
                            <button style="margin-top: 10px; height: 38px;background: #ec1666;color: #fff;" type="submit" class="btn">Confirm Now</button>
                        </div>
                    </div>

                </form>
            </div>
        </div>
    </div>

</div>
@endsection