index.blade.php 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. @extends('layouts.app')
  2. @section('title', 'Все посты')
  3. @section('content')
  4. <div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8">
  5. <div class="mb-8">
  6. <h1 class="text-4xl font-bold text-gray-900">Все публикации</h1>
  7. <p class="mt-2 text-gray-600">Читайте наши последние статьи и новости</p>
  8. </div>
  9. @if($posts->isEmpty())
  10. <div class="bg-white rounded-lg shadow-md p-12 text-center">
  11. <svg class="mx-auto h-12 w-12 text-gray-400" fill="none" stroke="currentColor" viewBox="0 0 24 24">
  12. <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 12h6m-6 4h6m2 5H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z"/>
  13. </svg>
  14. <h3 class="mt-2 text-sm font-medium text-gray-900">Постов пока нет</h3>
  15. <p class="mt-1 text-sm text-gray-500">Начните с создания нового поста</p>
  16. <div class="mt-6">
  17. <a href="{{ route('posts.create') }}" class="inline-flex items-center px-4 py-2 border border-transparent shadow-sm text-sm font-medium rounded-md text-white bg-indigo-600 hover:bg-indigo-700">
  18. <svg class="-ml-1 mr-2 h-5 w-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
  19. <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 4v16m8-8H4"/>
  20. </svg>
  21. Создать пост
  22. </a>
  23. </div>
  24. </div>
  25. @else
  26. <div class="grid gap-6 md:grid-cols-2 lg:grid-cols-3">
  27. @foreach($posts as $post)
  28. <article class="bg-white rounded-lg shadow-md overflow-hidden hover:shadow-xl transition-shadow duration-300">
  29. <div class="p-6">
  30. <div class="flex items-center text-sm text-gray-500 mb-3">
  31. <svg class="h-4 w-4 mr-1" fill="none" stroke="currentColor" viewBox="0 0 24 24">
  32. <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"/>
  33. </svg>
  34. <time datetime="{{ $post->published_at }}">
  35. {{ $post->published_at->format('d.m.Y') }}
  36. </time>
  37. </div>
  38. <h2 class="text-xl font-bold text-gray-900 mb-3 line-clamp-2">
  39. <a href="{{ route('posts.show', $post) }}" class="hover:text-indigo-600 transition-colors">
  40. {{ $post->title }}
  41. </a>
  42. </h2>
  43. <p class="text-gray-600 mb-4 line-clamp-3">
  44. {{ Str::limit(strip_tags($post->content), 150) }}
  45. </p>
  46. <div class="flex items-center justify-between">
  47. <a href="{{ route('posts.show', $post) }}" class="text-indigo-600 hover:text-indigo-800 font-medium text-sm flex items-center">
  48. Читать далее
  49. <svg class="w-4 h-4 ml-1" fill="none" stroke="currentColor" viewBox="0 0 24 24">
  50. <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 5l7 7-7 7"/>
  51. </svg>
  52. </a>
  53. <div class="flex items-center text-gray-500 text-sm">
  54. <svg class="h-4 w-4 mr-1" fill="none" stroke="currentColor" viewBox="0 0 24 24">
  55. <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"/>
  56. </svg>
  57. {{ $post->comments()->approved()->count() }}
  58. </div>
  59. </div>
  60. </div>
  61. </article>
  62. @endforeach
  63. </div>
  64. {{-- Пагинация --}}
  65. <div class="mt-8">
  66. {{ $posts->links() }}
  67. </div>
  68. @endif
  69. </div>
  70. @endsection