show.blade.php 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  1. @extends('layouts.app')
  2. @section('title', $post->title)
  3. @section('content')
  4. <div class="max-w-4xl mx-auto px-4 sm:px-6 lg:px-8">
  5. {{-- Кнопка назад --}}
  6. <div class="mb-6">
  7. <a href="{{ route('posts.index') }}" class="inline-flex items-center text-indigo-600 hover:text-indigo-800">
  8. <svg class="w-5 h-5 mr-1" fill="none" stroke="currentColor" viewBox="0 0 24 24">
  9. <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15 19l-7-7 7-7"/>
  10. </svg>
  11. Назад к постам
  12. </a>
  13. </div>
  14. {{-- Основная статья --}}
  15. <article class="bg-white rounded-lg shadow-lg overflow-hidden mb-8">
  16. <div class="p-8">
  17. {{-- Заголовок --}}
  18. <header class="mb-6">
  19. <h1 class="text-4xl font-bold text-gray-900 mb-4">{{ $post->title }}</h1>
  20. <div class="flex items-center text-gray-600 text-sm space-x-4">
  21. <div class="flex items-center">
  22. <svg class="h-5 w-5 mr-2" fill="none" stroke="currentColor" viewBox="0 0 24 24">
  23. <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"/>
  24. </svg>
  25. <time datetime="{{ $post->published_at }}">
  26. {{ $post->published_at->format('d F Y, H:i') }}
  27. </time>
  28. </div>
  29. <div class="flex items-center">
  30. <svg class="h-5 w-5 mr-2" fill="none" stroke="currentColor" viewBox="0 0 24 24">
  31. <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"/>
  32. </svg>
  33. {{ $comments->count() }} {{ Str::plural('comment', $comments->count()) }}
  34. </div>
  35. </div>
  36. </header>
  37. {{-- Контент поста --}}
  38. <div class="prose max-w-none text-gray-700 leading-relaxed">
  39. {!! nl2br(e($post->content)) !!}
  40. </div>
  41. </div>
  42. {{-- Действия с постом --}}
  43. <div class="bg-gray-50 px-8 py-4 border-t border-gray-200 flex items-center justify-between">
  44. <div class="flex space-x-4">
  45. <a href="{{ route('posts.edit', $post) }}" class="text-indigo-600 hover:text-indigo-800 font-medium text-sm">
  46. Редактировать
  47. </a>
  48. </div>
  49. <form action="{{ route('posts.destroy', $post) }}" method="POST" onsubmit="return confirm('Вы уверены?')">
  50. @csrf
  51. @method('DELETE')
  52. <button type="submit" class="text-red-600 hover:text-red-800 font-medium text-sm">
  53. Удалить пост
  54. </button>
  55. </form>
  56. </div>
  57. </article>
  58. {{-- Секция комментариев --}}
  59. <div class="bg-white rounded-lg shadow-lg p-8">
  60. <h2 class="text-2xl font-bold text-gray-900 mb-6">
  61. Комментарии ({{ $comments->count() }})
  62. </h2>
  63. {{-- Форма добавления комментария --}}
  64. <div class="mb-8 pb-8 border-b border-gray-200">
  65. <h3 class="text-lg font-semibold text-gray-900 mb-4">Оставить комментарий</h3>
  66. <form action="{{ route('comments.store', $post) }}" method="POST" class="space-y-4">
  67. @csrf
  68. <div class="grid grid-cols-1 md:grid-cols-2 gap-4">
  69. <div>
  70. <label for="author_name" class="block text-sm font-medium text-gray-700 mb-2">
  71. Имя *
  72. </label>
  73. <input type="text"
  74. name="author_name"
  75. id="author_name"
  76. required
  77. value="{{ old('author_name') }}"
  78. 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">
  79. @error('author_name')
  80. <p class="mt-1 text-sm text-red-600">{{ $message }}</p>
  81. @enderror
  82. </div>
  83. <div>
  84. <label for="author_email" class="block text-sm font-medium text-gray-700 mb-2">
  85. Email *
  86. </label>
  87. <input type="email"
  88. name="author_email"
  89. id="author_email"
  90. required
  91. value="{{ old('author_email') }}"
  92. 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">
  93. @error('author_email')
  94. <p class="mt-1 text-sm text-red-600">{{ $message }}</p>
  95. @enderror
  96. </div>
  97. </div>
  98. <div>
  99. <label for="content" class="block text-sm font-medium text-gray-700 mb-2">
  100. Комментарий *
  101. </label>
  102. <textarea name="content"
  103. id="content"
  104. rows="4"
  105. required
  106. maxlength="1000"
  107. 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>
  108. @error('content')
  109. <p class="mt-1 text-sm text-red-600">{{ $message }}</p>
  110. @enderror
  111. <p class="mt-1 text-sm text-gray-500">Максимум 1000 символов</p>
  112. </div>
  113. <div>
  114. <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">
  115. Отправить комментарий
  116. </button>
  117. </div>
  118. <p class="text-sm text-gray-500">
  119. * Ваш комментарий будет опубликован после модерации
  120. </p>
  121. </form>
  122. </div>
  123. {{-- Список комментариев --}}
  124. @if($comments->isEmpty())
  125. <div class="text-center py-8 text-gray-500">
  126. <svg class="mx-auto h-12 w-12 text-gray-400" fill="none" stroke="currentColor" viewBox="0 0 24 24">
  127. <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"/>
  128. </svg>
  129. <p class="mt-2">Комментариев пока нет. Будьте первым!</p>
  130. </div>
  131. @else
  132. <div class="space-y-6">
  133. @foreach($comments as $comment)
  134. <div class="border-l-4 border-indigo-500 pl-4 py-3">
  135. <div class="flex items-center justify-between mb-2">
  136. <div class="flex items-center space-x-2">
  137. <div class="w-10 h-10 bg-indigo-100 rounded-full flex items-center justify-center">
  138. <span class="text-indigo-600 font-semibold text-lg">
  139. {{ substr($comment->author_name, 0, 1) }}
  140. </span>
  141. </div>
  142. <div>
  143. <p class="font-semibold text-gray-900">{{ $comment->author_name }}</p>
  144. <p class="text-sm text-gray-500">{{ $comment->created_at->diffForHumans() }}</p>
  145. </div>
  146. </div>
  147. </div>
  148. <p class="text-gray-700 leading-relaxed">{{ $comment->content }}</p>
  149. </div>
  150. @endforeach
  151. </div>
  152. @endif
  153. </div>
  154. </div>
  155. @endsection