show.blade.php 3.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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. <div class="border-t pt-10">
  14. <h3 class="text-2xl font-bold text-gray-900 mb-6">Комментарии ({{ $post->comments->where('is_approved', true)->count() }})</h3>
  15. <div class="mb-10 bg-gray-50 p-6 rounded-lg">
  16. <h4 class="text-lg font-medium mb-4">Оставить комментарий</h4>
  17. <form action="{{ route('comments.store', $post) }}" method="POST">
  18. @csrf
  19. <div class="mb-4">
  20. <label for="author_name" class="block text-sm font-medium text-gray-700">Ваше имя</label>
  21. <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">
  22. </div>
  23. <div class="mb-4">
  24. <label for="body" class="block text-sm font-medium text-gray-700">Сообщение</label>
  25. <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>
  26. </div>
  27. <button type="submit" class="bg-indigo-600 text-white px-4 py-2 rounded-md hover:bg-indigo-700 text-sm font-medium transition">
  28. Отправить
  29. </button>
  30. </form>
  31. </div>
  32. <div class="space-y-6">
  33. @foreach($post->comments as $comment)
  34. @if($comment->is_approved)
  35. <div class="flex space-x-4">
  36. <div class="flex-shrink-0">
  37. <div class="h-10 w-10 rounded-full bg-indigo-100 flex items-center justify-center text-indigo-600 font-bold">
  38. {{ substr($comment->author_name, 0, 1) }}
  39. </div>
  40. </div>
  41. <div>
  42. <div class="text-sm font-bold text-gray-900">{{ $comment->author_name }}</div>
  43. <div class="text-xs text-gray-500">{{ $comment->created_at->diffForHumans() }}</div>
  44. <div class="mt-1 text-gray-700">
  45. {{ $comment->body }}
  46. </div>
  47. </div>
  48. </div>
  49. @else
  50. @auth
  51. <div class="flex space-x-4 opacity-50 border-l-2 border-yellow-400 pl-4">
  52. <div>
  53. <div class="text-sm font-bold text-gray-900">{{ $comment->author_name }} (На модерации)</div>
  54. <div class="mt-1 text-gray-700">{{ $comment->body }}</div>
  55. </div>
  56. </div>
  57. @endauth
  58. @endif
  59. @endforeach
  60. </div>
  61. </div>
  62. </article>
  63. @endsection