@extends('layouts.load')

@section('styles')
    <link rel="stylesheet" href="{{ asset('assets/admin/css/datetimepicker.css') }}">
@endsection

@section('content')

<div class="card shadow-none border-0 mb-0">
    <div class="card-body p-3">
        @include('includes.admin.form-both')
        <div class="gocover" style="background: url({{asset('assets/images/'.$gs->admin_loader)}}) no-repeat scroll center center rgba(45, 45, 45, 0.5);"></div>
        <form id="geniusformdataedit" action="{{ route('addPolls.update',$poll_option->id)}}" method="POST" enctype="multipart/form-data">
            {{csrf_field()}}

            <div class="mb-3">
                <label class="form-label">{{ __('Language') }} <span class="text-danger">*</span></label>
                <select name="language_id" class="form-select">
                    @foreach ($datas as $data)
                        <option value="{{$data->id}}" {{$data->id == $poll_option->language_id ? 'selected' : ''}}>{{$data->language}}</option>
                    @endforeach
                </select>
            </div>

            <div class="mb-3">
                <label class="form-label">{{ __('Question') }} <span class="text-danger">*</span></label>
                <textarea name="question" class="form-control" rows="3">{{ $poll_option->question }}</textarea>
            </div>

            <div class="pollOption">
                @if (count($poll_option->child)>0)
                @foreach ($poll_option->child as $item)
                    <input type="hidden" name="option_id" value="{{$item->id}}">
                    <div class="mb-3">
                        <label class="form-label">{{ __('Poll Option') }} <span class="text-danger">*</span></label>
                        <input type="text" name="poll_option[]" class="form-control" placeholder="poll option here" value="{{ $item->poll_option }}" autocomplete="off">
                    </div>
                @endforeach
                @else
                    <p class="text-danger">{{__('No Poll Option Create yet')}}</p>
                @endif
            </div>

            <div class="mb-3">
                <a href="javascript:;" id="poll-option" class="btn btn-sm btn-dark"><i class="icofont-plus"></i> {{__('Add More Option')}}</a>
            </div>

            <div class="mb-3">
                <label class="form-label">{{ __('End Date') }} <span class="text-danger">*</span></label>
                <input id="from" class="form-control" type="text" name="end_date" autocomplete="off" placeholder="{{__('End Date')}}" value="{{ $poll_option->end_date }}">
            </div>

            <div class="mb-3">
                <label class="form-label d-block">{{__('Status')}} <span class="text-danger">*</span></label>
                <div class="form-check form-check-inline">
                    <input class="form-check-input" type="radio" name="status" value="1" id="enable" {{ $poll_option->status == 1 ? 'checked' : ''}}>
                    <label class="form-check-label" for="enable">{{__('Enable')}}</label>
                </div>
                <div class="form-check form-check-inline">
                    <input class="form-check-input" type="radio" name="status" id="disable" value="0" {{ $poll_option->status == 0 ? 'checked' : ''}}>
                    <label class="form-check-label" for="disable">{{__('Disable')}}</label>
                </div>
            </div>

            <button class="btn btn-primary w-100" type="submit">{{ __('Update Polls') }}</button>
        </form>
    </div>
</div>

@endsection

@section('scripts')
<script src="{{asset('assets/admin/js/datetimepicker.js')}}"></script>
<script src="{{asset('assets/admin/js/poll.js')}}"></script>
@endsection