@extends('admin::layouts.master')

@section('title', '信息页面')

@push('header')
  <script src="{{ asset('vendor/tinymce/5.9.1/tinymce.min.js') }}"></script>
@endpush

@section('content')
  <div id="plugins-app-form" class="card h-min-600">
    <div class="card-body">
      <form novalidate class="needs-validation" action="{{ $page->id ? admin_route('pages.update', [$page->id]) : admin_route('pages.store') }}" method="POST">
        @csrf
        @method($page->id ? 'PUT' : 'POST')

        <ul class="nav nav-tabs nav-bordered mb-3" role="tablist">
          @foreach ($admin_languages as $language)
            <li class="nav-item" role="presentation">
              <button class="nav-link {{ $loop->first ? 'active' : '' }}" data-bs-toggle="tab" data-bs-target="#tab-{{ $language['code'] }}" type="button" >{{ $language['name'] }}</button>
            </li>
          @endforeach
        </ul>
        <div class="tab-content">
          @foreach ($admin_languages as $language)
            <div class="tab-pane fade {{ $loop->first ? 'show active' : '' }}" id="tab-{{ $language['code'] }}">
              @php
                $error_title = $errors->first("descriptions.{$language['code']}.title");
              @endphp
              <x-admin-form-input
                error="{{ $error_title }}"
                name="descriptions[{{ $language['code'] }}][title]"
                title="信息标题"
                :required="true"
                value="{{ old('title', $descriptions[$language['code']]['title'] ?? '') }}"
              />

              <x-admin::form.row title="内容">
                <div class="w-max-1000">
                  <textarea required name="descriptions[{{ $language['code'] }}][content]" data-tinymce-height="600" class="form-control tinymce">
                    {{ old('content', $descriptions[$language['code']]['content'] ?? '') }}
                  </textarea>
                </div>
                @if ($errors->has("descriptions.{$language['code']}.content"))
                  <span class="invalid-feedback d-block" role="alert">{{ $errors->first("descriptions.{$language['code']}.content") }}</span>
                @endif
              </x-admin::form.row>
              <input type="hidden" name="descriptions[{{ $language['code'] }}][locale]" value="{{ $language['code'] }}">
              <x-admin-form-input name="descriptions[{{ $language['code'] }}][meta_title]" title="Meta Tag 标题" value="{{ old('meta_title', $descriptions[$language['code']]['meta_title'] ?? '') }}" />
              <x-admin-form-input name="descriptions[{{ $language['code'] }}][meta_description]" title="Meta Tag 描述" value="{{ old('meta_description', $descriptions[$language['code']]['meta_description'] ?? '') }}" />
              <x-admin-form-input name="descriptions[{{ $language['code'] }}][meta_keyword]" title="Meta Tag 关键字" value="{{ old('meta_keyword', $descriptions[$language['code']]['meta_keyword'] ?? '') }}" />
            </div>
          @endforeach

          <x-admin-form-switch name="active" title="状态" value="{{ old('active', 1) }}" />
          <x-admin::form.row title="">
            <button type="submit" class="mt-3 btn btn-primary">提交</button>
          </x-admin::form.row>
        </div>
      </form>
    </div>
  </div>
@endsection

@push('footer')
  <script>
    $(function() {

    });
  </script>
@endpush



