<x-app-layout>
    @section('title')
        Plat Form Create
    @endsection


    <!-- DataTales Example -->
    <div class="row">
        <div class="col-md-7 m-auto">
            <!-- Page Heading -->
            <h1 class="h3 mb-2 text-gray-800">
                @can('Plat Form access')
                    <a href="{{ route('admin.platforms.index') }}" class="btn btn-primary"><i class="fas fa-plus"
                            aria-hidden="true"></i>
                        Plat Form Listing
                    </a>
                @endcan
            </h1>
            <form action="{{ route('admin.platforms.store') }}" method="POST" enctype="multipart/form-data"
                class="needs-validation" role="form" novalidate>
                @csrf
                <div class="card shadow mb-4">
                    <div class="card-header py-3">
                        <h6 class="m-0 font-weight-bold text-primary">Plat Form</h6>
                    </div>
                    <div class="card-body">



                        <div class="form-group">
                            <label class="mb-0" for="image">Image <span class="text-danger">*</span></label>
                            <input type="file" name="image" id="image"
                                class="mb-2 form-control @error('image') is-invalid @enderror" />
                            <div id="showImage" style="display: none" class="mt-2">
                                <img class="img-fuild" width="150px" height="120px" id="prevImg" src="#"
                                    alt="" style="border: 1px dotted #000">
                                @error('image')
                                    <span class="text-danger">{{ $message }}</span>
                                @enderror
                            </div>
                        </div>


                        <div class="form-group">
                            <label class="mb-0" for="status">Status <span class="text-danger">*</span></label>
                            <select name="status" id="status"
                                class="form-control @error('status') is-invalid @enderror">
                                <option value="1">Active</option>
                                <option value="0">Inactive</option>
                            </select>
                            @error('status')
                                <span class="text-danger">{{ $message }}</span>
                            @enderror
                        </div>





                    </div>

                    <div class="card-footer text-right">
                        <button type="submit" class="btn btn-success">Save</button>
                    </div>

                </div>
            </form>
        </div>
    </div>
    @section('script')
        <script>
            $(document).ready(() => {
                // Banner Image
                $('#image').change(function() {
                    const file = this.files[0];
                    console.log(file);
                    if (file) {
                        let reader = new FileReader();
                        reader.onload = function(event) {
                            console.log(event.target.result);
                            $('#prevImg').attr('src', event.target.result);
                            $("#showImage").css('display', 'block')
                        }
                        reader.readAsDataURL(file);
                    }
                });

            });
        </script>

        <script>
            $('input[name="tags"]').amsifySuggestags({
                type: 'amsify',
                suggestions: ['Mercury', 'Venus', 'Earth', 'Mars', 'Jupitor', 'Uranus', 'Neptune', 'Pluto'],
            });
        </script>
    @endsection
</x-app-layout>
