index.blade.php 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. @extends('layouts.app')
  2. @section('content')
  3. <h1 class="text-3xl font-bold mb-6">Все публикации</h1>
  4. <div class="grid gap-6">
  5. @foreach($posts as $post)
  6. <div class="bg-white p-6 rounded shadow flex justify-between items-center">
  7. <div>
  8. <a href="{{ route('posts.show', $post) }}" class="text-xl font-semibold hover:underline">
  9. {{ $post->title }}
  10. </a>
  11. <div class="text-sm text-gray-500">
  12. Статус:
  13. <span class="{{ $post->is_published ? 'text-green-600' : 'text-orange-600' }}">
  14. {{ $post->is_published ? 'Опубликован' : 'Черновик' }}
  15. </span>
  16. @if($post->published_at) | План: {{ $post->published_at }} @endif
  17. </div>
  18. </div>
  19. <div class="flex space-x-2">
  20. <form action="{{ route('posts.publish', $post) }}" method="POST">
  21. @csrf
  22. <button class="bg-gray-200 px-3 py-1 rounded text-sm">
  23. {{ $post->is_published ? 'Снять' : 'Опубликовать' }}
  24. </button>
  25. </form>
  26. <a href="{{ route('posts.edit', $post) }}" class="bg-blue-500 text-white px-3 py-1 rounded text-sm">Ред.</a>
  27. <form action="{{ route('posts.destroy', $post) }}" method="POST">
  28. @csrf @method('DELETE')
  29. <button class="bg-red-500 text-white px-3 py-1 rounded text-sm">Удалить</button>
  30. </form>
  31. </div>
  32. </div>
  33. @endforeach
  34. </div>
  35. @endsection