show.blade.php 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. @extends('layout')
  2. @section('content')
  3. <article class="prose prose-indigo prose-lg mx-auto bg-white p-8 rounded-xl shadow-sm border border-gray-100">
  4. <div class="mb-8 border-b pb-8">
  5. <h1 class="text-4xl font-bold text-gray-900 mb-2">{{ $post->title }}</h1>
  6. <span class="text-gray-500 text-sm">
  7. Опубликовано: {{ $post->published_at ? $post->published_at->format('d F Y') : 'Не опубликовано' }}
  8. </span>
  9. </div>
  10. <div class="text-gray-700 leading-relaxed mb-12">
  11. {!! nl2br(e($post->content)) !!}
  12. </div>
  13. <!-- Секция комментариев -->
  14. <div class="border-t pt-10">
  15. <h3 class="text-2xl font-bold text-gray-900 mb-6">Комментарии ({{ $post->comments->where('is_approved', true)->count() }})</h3>
  16. <!-- Форма добавления -->
  17. <div class="mb-10 bg-gray-50 p-6 rounded-lg">
  18. <h4 class="text-lg font-medium mb-4">Оставить комментарий</h4>
  19. <form action="{{ route('comments.store', $post) }}" method="POST">
  20. @csrf
  21. <div class="mb-4">
  22. <label for="author_name" class="block text-sm font-medium text-gray-700">Ваше имя</label>
  23. <input type="text" name="author_name" id="author_name" required class="mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500 p-2 border">
  24. </div>
  25. <div class="mb-4">
  26. <label for="body" class="block text-sm font-medium text-gray-700">Сообщение</label>
  27. <textarea name="body" id="body" rows="3" required class="mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500 p-2 border"></textarea>
  28. </div>
  29. <button type="submit" class="bg-indigo-600 text-white px-4 py-2 rounded-md hover:bg-indigo-700 text-sm font-medium transition">
  30. Отправить
  31. </button>
  32. </form>
  33. </div>
  34. <!-- Список комментариев -->
  35. <div class="space-y-6">
  36. @foreach($post->comments as $comment)
  37. @if($comment->is_approved)
  38. <div class="flex space-x-4">
  39. <div class="flex-shrink-0">
  40. <div class="h-10 w-10 rounded-full bg-indigo-100 flex items-center justify-center text-indigo-600 font-bold">
  41. {{ substr($comment->author_name, 0, 1) }}
  42. </div>
  43. </div>
  44. <div>
  45. <div class="text-sm font-bold text-gray-900">{{ $comment->author_name }}</div>
  46. <div class="text-xs text-gray-500">{{ $comment->created_at->diffForHumans() }}</div>
  47. <div class="mt-1 text-gray-700">
  48. {{ $comment->body }}
  49. </div>
  50. </div>
  51. </div>
  52. @else
  53. @auth
  54. <!-- Админ видит неодобренные комменты -->
  55. <div class="flex space-x-4 opacity-50 border-l-2 border-yellow-400 pl-4">
  56. <div>
  57. <div class="text-sm font-bold text-gray-900">{{ $comment->author_name }} (На модерации)</div>
  58. <div class="mt-1 text-gray-700">{{ $comment->body }}</div>
  59. </div>
  60. </div>
  61. @endauth
  62. @endif
  63. @endforeach
  64. </div>
  65. </div>
  66. </article>
  67. @endsection