@php($title = 'Новости')
@extends('layouts.admin')
@section('content')
    <link rel="stylesheet" type="text/css" href="https://unpkg.com/trix@2.0.8/dist/trix.css">
    <script type="text/javascript" src="https://unpkg.com/trix@2.0.8/dist/trix.umd.min.js"></script>

    <h4 class="fw-bold">Добавить новость</h4>
    <form action="{{ route('admin.posts.store') }}" method="post" enctype="multipart/form-data">
        @csrf
        <div class="mb-3">
            <label for="titleFormControlTextarea" class="form-label">Заголовок</label>
            <textarea class="form-control" id="titleFormControlTextarea1" name="name" rows="2"></textarea>
            @error('name')
                <div class="text-danger">{{ $message }}</div>
            @enderror
        </div>
        <div class="row">
            <div class="col-6 mb-3">
                <label for="categoryFormControlSelect" class="form-label">Категория</label>
                <select class="form-select" id="categoryFormControlSelect" name="category" aria-label="">
                    @foreach ($categories as $category)
                        <option value="{{ $category->value }}">{{ __($category->name) }}</option>
                    @endforeach
                </select>
                @error('category')
                    <div class="text-danger">{{ $message }}</div>
                @enderror
            </div>
            <div class="col-6 mb-3">
                <label for="formFile" class="form-label">Заставка новости</label>
                <input class="form-control" type="file" id="formFile" name="imageFile">
                @error('imageFile')
                    <div class="text-danger">{{ $message }}</div>
                @enderror
            </div>
        </div>
        <div class="mb-3">
            <label for="shortTextFormControlTextarea" class="form-label">Анонс</label>
            <textarea class="form-control" id="shortTextFormControlTextarea1" name="short_text" rows="3"></textarea>
            @error('short_text')
                <div class="text-danger">{{ $message }}</div>
            @enderror
        </div>
        <div class="mb-3">
            <label for="shortTextFormControlTextarea" class="form-label">Основной текст</label>
            <textarea class="form-control d-none" id="textFormControlTextarea" name="text" rows="15"></textarea>
            <trix-editor input="textFormControlTextarea" class="overflow-auto" style="height:300px"></trix-editor>
            @error('text')
                <div class="text-danger">{{ $message }}</div>
            @enderror
        </div>
        <input type="text" name="cities[0]" value="1" />
        <button type="submit" class="btn btn-primary">Сохранить</button>
    </form>
@endsection
