| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172 |
- @extends('layouts.app')
- @section('title', $post->title)
- @section('content')
- <div class="max-w-4xl mx-auto px-4 sm:px-6 lg:px-8">
- {{-- Кнопка назад --}}
- <div class="mb-6">
- <a href="{{ route('posts.index') }}" class="inline-flex items-center text-indigo-600 hover:text-indigo-800">
- <svg class="w-5 h-5 mr-1" fill="none" stroke="currentColor" viewBox="0 0 24 24">
- <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15 19l-7-7 7-7"/>
- </svg>
- Назад к постам
- </a>
- </div>
- {{-- Основная статья --}}
- <article class="bg-white rounded-lg shadow-lg overflow-hidden mb-8">
- <div class="p-8">
- {{-- Заголовок --}}
- <header class="mb-6">
- <h1 class="text-4xl font-bold text-gray-900 mb-4">{{ $post->title }}</h1>
-
- <div class="flex items-center text-gray-600 text-sm space-x-4">
- <div class="flex items-center">
- <svg class="h-5 w-5 mr-2" fill="none" stroke="currentColor" viewBox="0 0 24 24">
- <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M8 7V3m8 4V3m-9 8h10M5 21h14a2 2 0 002-2V7a2 2 0 00-2-2H5a2 2 0 00-2 2v12a2 2 0 002 2z"/>
- </svg>
- <time datetime="{{ $post->published_at }}">
- {{ $post->published_at->format('d F Y, H:i') }}
- </time>
- </div>
-
- <div class="flex items-center">
- <svg class="h-5 w-5 mr-2" fill="none" stroke="currentColor" viewBox="0 0 24 24">
- <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M7 8h10M7 12h4m1 8l-4-4H5a2 2 0 01-2-2V6a2 2 0 012-2h14a2 2 0 012 2v8a2 2 0 01-2 2h-3l-4 4z"/>
- </svg>
- {{ $comments->count() }} {{ Str::plural('comment', $comments->count()) }}
- </div>
- </div>
- </header>
- {{-- Контент поста --}}
- <div class="prose max-w-none text-gray-700 leading-relaxed">
- {!! nl2br(e($post->content)) !!}
- </div>
- </div>
- {{-- Действия с постом --}}
- <div class="bg-gray-50 px-8 py-4 border-t border-gray-200 flex items-center justify-between">
- <div class="flex space-x-4">
- <a href="{{ route('posts.edit', $post) }}" class="text-indigo-600 hover:text-indigo-800 font-medium text-sm">
- Редактировать
- </a>
- </div>
-
- <form action="{{ route('posts.destroy', $post) }}" method="POST" onsubmit="return confirm('Вы уверены?')">
- @csrf
- @method('DELETE')
- <button type="submit" class="text-red-600 hover:text-red-800 font-medium text-sm">
- Удалить пост
- </button>
- </form>
- </div>
- </article>
- {{-- Секция комментариев --}}
- <div class="bg-white rounded-lg shadow-lg p-8">
- <h2 class="text-2xl font-bold text-gray-900 mb-6">
- Комментарии ({{ $comments->count() }})
- </h2>
- {{-- Форма добавления комментария --}}
- <div class="mb-8 pb-8 border-b border-gray-200">
- <h3 class="text-lg font-semibold text-gray-900 mb-4">Оставить комментарий</h3>
-
- <form action="{{ route('comments.store', $post) }}" method="POST" class="space-y-4">
- @csrf
-
- <div class="grid grid-cols-1 md:grid-cols-2 gap-4">
- <div>
- <label for="author_name" class="block text-sm font-medium text-gray-700 mb-2">
- Имя *
- </label>
- <input type="text"
- name="author_name"
- id="author_name"
- required
- value="{{ old('author_name') }}"
- class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-indigo-500 focus:border-transparent @error('author_name') border-red-500 @enderror">
- @error('author_name')
- <p class="mt-1 text-sm text-red-600">{{ $message }}</p>
- @enderror
- </div>
- <div>
- <label for="author_email" class="block text-sm font-medium text-gray-700 mb-2">
- Email *
- </label>
- <input type="email"
- name="author_email"
- id="author_email"
- required
- value="{{ old('author_email') }}"
- class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-indigo-500 focus:border-transparent @error('author_email') border-red-500 @enderror">
- @error('author_email')
- <p class="mt-1 text-sm text-red-600">{{ $message }}</p>
- @enderror
- </div>
- </div>
- <div>
- <label for="content" class="block text-sm font-medium text-gray-700 mb-2">
- Комментарий *
- </label>
- <textarea name="content"
- id="content"
- rows="4"
- required
- maxlength="1000"
- class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-indigo-500 focus:border-transparent @error('content') border-red-500 @enderror">{{ old('content') }}</textarea>
- @error('content')
- <p class="mt-1 text-sm text-red-600">{{ $message }}</p>
- @enderror
- <p class="mt-1 text-sm text-gray-500">Максимум 1000 символов</p>
- </div>
- <div>
- <button type="submit" class="px-6 py-3 bg-indigo-600 text-white font-medium rounded-lg hover:bg-indigo-700 focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:ring-offset-2">
- Отправить комментарий
- </button>
- </div>
- <p class="text-sm text-gray-500">
- * Ваш комментарий будет опубликован после модерации
- </p>
- </form>
- </div>
- {{-- Список комментариев --}}
- @if($comments->isEmpty())
- <div class="text-center py-8 text-gray-500">
- <svg class="mx-auto h-12 w-12 text-gray-400" fill="none" stroke="currentColor" viewBox="0 0 24 24">
- <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M8 12h.01M12 12h.01M16 12h.01M21 12c0 4.418-4.03 8-9 8a9.863 9.863 0 01-4.255-.949L3 20l1.395-3.72C3.512 15.042 3 13.574 3 12c0-4.418 4.03-8 9-8s9 3.582 9 8z"/>
- </svg>
- <p class="mt-2">Комментариев пока нет. Будьте первым!</p>
- </div>
- @else
- <div class="space-y-6">
- @foreach($comments as $comment)
- <div class="border-l-4 border-indigo-500 pl-4 py-3">
- <div class="flex items-center justify-between mb-2">
- <div class="flex items-center space-x-2">
- <div class="w-10 h-10 bg-indigo-100 rounded-full flex items-center justify-center">
- <span class="text-indigo-600 font-semibold text-lg">
- {{ substr($comment->author_name, 0, 1) }}
- </span>
- </div>
- <div>
- <p class="font-semibold text-gray-900">{{ $comment->author_name }}</p>
- <p class="text-sm text-gray-500">{{ $comment->created_at->diffForHumans() }}</p>
- </div>
- </div>
- </div>
- <p class="text-gray-700 leading-relaxed">{{ $comment->content }}</p>
- </div>
- @endforeach
- </div>
- @endif
- </div>
- </div>
- @endsection
|