@extends('admin.layouts.app')

@push('styles_top')
    <link rel="stylesheet" href="/assets/admin/vendor/bootstrap-colorpicker/bootstrap-colorpicker.min.css">
@endpush

@section('content')
    <section class="section">
        <div class="section-header">
            <h1>{{ trans('admin/main.create_trend_category') }}</h1>
            <div class="section-header-breadcrumb">
                <div class="breadcrumb-item active"><a href="/admin/">{{trans('admin/main.dashboard')}}</a>
                </div>
                <div class="breadcrumb-item">{{ trans('admin/main.create_trend_category') }}</div>
            </div>
        </div>

        <div class="section-body">

            <div class="row">
                <div class="col-12 col-md-6 col-lg-6">
                    <div class="card mt-4">
                        <div class="card-body">
                            <form action="/admin/categories/trends/{{ !empty($trend) ? $trend->id.'/update' : 'store' }}"
                                  method="Post">
                                {{ csrf_field() }}

                                {{--<div class="form-group">
                                    <label>{{ trans('/admin/main.category') }}</label>
                                    <select class="form-control @error('category_id') is-invalid @enderror" name="category_id">
                                        <option {{ !empty($trend) ? '' : 'selected' }} disabled>{{ trans('admin/main.choose_category') }}</option>

                                        @foreach($categories as $category)
                                            @if(!empty($category->subCategories) and count($category->subCategories))
                                                <optgroup label="{{  $category->title }}">
                                                    @foreach($category->subCategories as $subCategory)
                                                        <option value="{{ $subCategory->id }}" @if(!empty($trend) and $trend->category_id == $subCategory->id) selected="selected" @endif>{{ $subCategory->title }}</option>
                                                    @endforeach
                                                </optgroup>
                                            @else
                                                <option value="{{ $category->id }}" @if(!empty($trend) and $trend->category_id == $category->id) selected="selected" @endif>{{ $category->title }}</option>
                                            @endif
                                        @endforeach
                                    </select>
                                    @error('category_id')
                                    <div class="invalid-feedback">
                                        {{ $message }}
                                    </div>
                                    @enderror
                                </div>--}}
                                
                                @if(!empty(getGeneralSettings('content_translate')))
                    <div class="form-group">
                        <label class="input-label">{{ trans('auth.language') }}</label>
                        <select name="locale" class="form-control {{ !empty($slider) ? 'js-edit-content-locale' : '' }}">
                            @foreach($userLanguages as $lang => $language)
                                <option value="{{ $lang }}" @if(mb_strtolower(!empty($selectedLocale) ? $selectedLocale : app()->getLocale()) == mb_strtolower($lang)) selected @endif>{{ $language }}</option>
                            @endforeach
                        </select>
                        @error('locale')
                        <div class="invalid-feedback">
                            {{ $message }}
                        </div>
                        @enderror
                    </div>
                @else
                    <input type="hidden" name="locale" value="{{ getDefaultLocale() }}">
                @endif

             <div class="form-group">
                    <label>{{ trans('admin/main.title') }}</label>
                    <input type="text" name="title" value="{{ (!empty($trend) and !empty($trend->title)) ? $trend->title : old('title') }}" class="form-control @error('title') is-invalid @enderror"/>
                    @error('title')
                    <div class="invalid-feedback">
                        {{ $message }}
                    </div>
                    @enderror
                </div>

                                <div class="form-group">
                                    <label class="input-label">{{ trans('admin/main.trend_icon') }}</label>
                                    <div class="input-group">
                                        <div class="input-group-prepend">
                                            <button type="button" class="input-group-text admin-file-manager" data-input="icon" data-preview="holder">
                                                <i class="fa fa-chevron-up"></i>
                                            </button>
                                        </div>
                                        <input type="text" name="icon" id="icon" value="{{ !empty($trend) ? $trend->icon : old('icon') }}" class="form-control @error('icon') is-invalid @enderror">
                                        <div class="input-group-append">
                                            <button type="button" class="input-group-text admin-file-view" data-input="icon">
                                                <i class="fa fa-eye"></i>
                                            </button>
                                        </div>
                                        @error('icon')
                                        <div class="invalid-feedback">
                                            {{ $message }}
                                        </div>
                                        @enderror
                                    </div>
                                </div>
                                
                                <!---->
                                <div class="form-group">
                                    <label class="input-label">URL</label>
                                     <input type="url" name="url" value="{{ (!empty($trend) and !empty($trend->url)) ? $trend->url : old('url') }}" class="form-control @error('url') is-invalid @enderror"/>
                    @error('url')
                    <div class="invalid-feedback">
                        {{ $message }}
                    </div>
                    @enderror
                                    
                                </div>
                                <!---->

                                <div class="form-group">
                                    <label>{{ trans('admin/main.trend_color') }}</label>

                                    <div class="input-group colorpickerinput">
                                        <input type="text" name="color"
                                               autocomplete="off"
                                               class="form-control  @error('color') is-invalid @enderror"
                                               value="{{ !empty($trend) ? $trend->color : old('color') }}"
                                               placeholder="{{ trans('admin/main.trend_color_placeholder') }}"
                                        />

                                        <div class="input-group-append">
                                            <div class="input-group-text">
                                                <i class="fas fa-fill-drip"></i>
                                            </div>
                                        </div>

                                        @error('color')
                                        <div class="invalid-feedback">
                                            {{ $message }}
                                        </div>
                                        @enderror
                                    </div>
                                </div>
                                
                                <div class="form-group">
                                    <label class="input-label">courses no</label>
                                    {{--<div class="input-group">
                                        <div class="input-group-prepend">
                                            <button type="button" class="input-group-text admin-file-manager" data-input="courses_no" data-preview="holder">
                                                <i class="fa fa-chevron-up"></i>
                                            </button>
                                        </div>
                                        <input type="number" name="courses_no" id="courses_no" value="{{ !empty($trend) ? $trend->courses_no : old('courses_no') }}" class="form-control @error('courses_no') is-invalid @enderror">
                                        <div class="input-group-append">
                                            <button type="button" class="input-group-text admin-file-view" data-input="courses_no">
                                                <i class="fa fa-eye"></i>
                                            </button>
                                        </div>
                                        @error('courses_no')
                                        <div class="invalid-feedback">
                                            {{ $message }}
                                        </div>
                                        @enderror
                                    </div>--}}
                                      <input type="text" name="courses_no" value="{{ (!empty($trend) and !empty($trend->courses_no)) ? $trend->courses_no : old('courses_no') }}" class="form-control @error('courses_no') is-invalid @enderror"/>
                                @error('courses_no')
                    <div class="invalid-feedback">
                        {{ $message }}
                    </div>
                    @enderror
                                </div>

                                <div class="text-right mt-4">
                                    <button class="btn btn-primary">{{ trans('admin/main.submit') }}</button>
                                </div>
                            </form>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </section>
@endsection

@push('scripts_bottom')
    <script src="/assets/admin/vendor/bootstrap-colorpicker/bootstrap-colorpicker.min.js"></script>
    <script src="/assets/default/js/admin/categories.min.js"></script>
@endpush
