index.blade.php 3.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. @extends('layout')
  2. @section('content')
  3. <div class="space-y-6">
  4. <div class="flex justify-between items-center">
  5. <h1 class="text-3xl font-bold text-gray-900">Управление статьями</h1>
  6. <a href="{{ route('admin.posts.create') }}" class="bg-indigo-600 text-white px-4 py-2 rounded-md hover:bg-indigo-700 transition">
  7. + Создать статью
  8. </a>
  9. </div>
  10. <div class="bg-white shadow-sm border border-gray-100 rounded-lg overflow-hidden">
  11. <table class="min-w-full divide-y divide-gray-200">
  12. <thead class="bg-gray-50">
  13. <tr>
  14. <th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Заголовок</th>
  15. <th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Статус</th>
  16. <th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Дата публикации</th>
  17. <th scope="col" class="px-6 py-3 text-right text-xs font-medium text-gray-500 uppercase tracking-wider">Действия</th>
  18. </tr>
  19. </thead>
  20. <tbody class="bg-white divide-y divide-gray-200">
  21. @forelse($posts as $post)
  22. <tr>
  23. <td class="px-6 py-4 whitespace-nowrap">
  24. <div class="text-sm font-medium text-gray-900">{{ $post->title }}</div>
  25. <div class="text-sm text-gray-500 text-xs">{{ Str::limit($post->slug, 30) }}</div>
  26. </td>
  27. <td class="px-6 py-4 whitespace-nowrap">
  28. @if($post->is_published)
  29. <span class="px-2 inline-flex text-xs leading-5 font-semibold rounded-full bg-green-100 text-green-800">
  30. Опубликовано
  31. </span>
  32. @else
  33. <span class="px-2 inline-flex text-xs leading-5 font-semibold rounded-full bg-yellow-100 text-yellow-800">
  34. Черновик
  35. </span>
  36. @endif
  37. </td>
  38. <td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">
  39. {{ $post->published_at ? $post->published_at->format('d.m.Y H:i') : ($post->scheduled_at ? 'Запл.: ' . $post->scheduled_at->format('d.m H:i') : '-') }}
  40. </td>
  41. <td class="px-6 py-4 whitespace-nowrap text-right text-sm font-medium space-x-2">
  42. <a href="{{ route('admin.posts.edit', $post) }}" class="text-indigo-600 hover:text-indigo-900">Ред.</a>
  43. <form action="{{ route('admin.posts.destroy', $post) }}" method="POST" class="inline-block" onsubmit="return confirm('Удалить статью?');">
  44. @csrf
  45. @method('DELETE')
  46. <button type="submit" class="text-red-600 hover:text-red-900 ml-2">Удалить</button>
  47. </form>
  48. </td>
  49. </tr>
  50. @empty
  51. <tr>
  52. <td colspan="4" class="px-6 py-4 text-center text-gray-500">
  53. Статей пока нет. Создайте первую!
  54. </td>
  55. </tr>
  56. @endforelse
  57. </tbody>
  58. </table>
  59. </div>
  60. <div class="mt-4">
  61. {{ $posts->links() }}
  62. </div>
  63. </div>
  64. @endsection