form.blade.php 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. @extends('layout')
  2. @section('content')
  3. <div class="bg-white p-8 rounded-lg shadow-sm border border-gray-100">
  4. <h2 class="text-2xl font-bold mb-6">{{ isset($post) ? 'Редактировать статью' : 'Новая статья' }}</h2>
  5. <form action="{{ isset($post) ? route('admin.posts.update', $post) : route('admin.posts.store') }}" method="POST">
  6. @csrf
  7. @if(isset($post)) @method('PUT') @endif
  8. <div class="space-y-6">
  9. <div>
  10. <label class="block text-sm font-medium text-gray-700">Заголовок</label>
  11. <input type="text" name="title" value="{{ old('title', $post->title ?? '') }}" class="mt-1 block w-full rounded-md border border-gray-300 p-2 shadow-sm focus:border-indigo-500 focus:ring-indigo-500">
  12. </div>
  13. <div>
  14. <label class="block text-sm font-medium text-gray-700">Текст статьи</label>
  15. <textarea name="content" rows="10" class="mt-1 block w-full rounded-md border border-gray-300 p-2 shadow-sm focus:border-indigo-500 focus:ring-indigo-500">{{ old('content', $post->content ?? '') }}</textarea>
  16. </div>
  17. <div class="grid grid-cols-1 md:grid-cols-2 gap-6 bg-gray-50 p-4 rounded-md">
  18. <div>
  19. <label class="block text-sm font-medium text-gray-700">Запланировать публикацию (дата/время)</label>
  20. <input type="datetime-local" name="scheduled_at" value="{{ old('scheduled_at', isset($post) && $post->scheduled_at ? $post->scheduled_at->format('Y-m-d\TH:i') : '') }}" class="mt-1 block w-full rounded-md border border-gray-300 p-2">
  21. <p class="text-xs text-gray-500 mt-1">Оставьте пустым для немедленной публикации или черновика</p>
  22. </div>
  23. <div class="flex items-center mt-6">
  24. <input type="checkbox" name="is_published" id="is_published" value="1" {{ old('is_published', $post->is_published ?? false) ? 'checked' : '' }} class="h-4 w-4 text-indigo-600 focus:ring-indigo-500 border-gray-300 rounded">
  25. <label for="is_published" class="ml-2 block text-sm text-gray-900">
  26. Опубликовать немедленно?
  27. </label>
  28. </div>
  29. </div>
  30. <div class="flex justify-end gap-3">
  31. <a href="{{ route('admin.posts.index') }}" class="px-4 py-2 bg-gray-200 text-gray-700 rounded-md hover:bg-gray-300">Отмена</a>
  32. <button type="submit" class="px-4 py-2 bg-indigo-600 text-white rounded-md hover:bg-indigo-700 shadow-sm">
  33. {{ isset($post) ? 'Обновить' : 'Создать' }}
  34. </button>
  35. </div>
  36. </div>
  37. </form>
  38. </div>
  39. @endsection