75 lines
5.1 KiB
PHP
75 lines
5.1 KiB
PHP
<x-app-layout>
|
|||
|
|
<section class="bg-white dark:bg-gray-900 border-b border-gray-100 dark:border-gray-800">
|
||
|
|
<div class="mx-auto max-w-7xl px-4 sm:px-6 lg:px-8 py-8">
|
||
|
|
<div class="flex items-center justify-between">
|
||
|
|
<div>
|
||
|
|
<h1 class="text-2xl sm:text-3xl font-extrabold tracking-tight text-gray-900 dark:text-white">Manage Posts</h1>
|
||
|
|
<p class="mt-2 text-gray-600 dark:text-gray-300">Write, edit, and publish blog posts.</p>
|
||
|
|
</div>
|
||
|
|
<a href="{{ route('admin.posts.create') }}" class="inline-flex items-center rounded-xl bg-gradient-to-r from-fuchsia-600 to-indigo-600 px-4 py-2 text-sm font-semibold text-white shadow hover:from-fuchsia-500 hover:to-indigo-500">New Post</a>
|
||
|
|
</div>
|
||
|
|
</div>
|
||
|
|
</section>
|
||
|
|
|
||
|
|
<section class="mx-auto max-w-7xl px-4 sm:px-6 lg:px-8 py-6">
|
||
|
|
@if(session('status'))
|
||
|
|
<div class="mb-4 rounded-xl bg-emerald-50 text-emerald-700 px-4 py-3">{{ session('status') }}</div>
|
||
|
|
@endif
|
||
|
|
|
||
|
|
<form action="{{ route('admin.posts.index') }}" method="GET" class="mb-4 flex items-end gap-3 bg-white dark:bg-gray-800 rounded-2xl p-4 ring-1 ring-gray-200 dark:ring-gray-700">
|
||
|
|
<div class="w-full sm:w-80">
|
||
|
|
<label class="block text-sm font-medium text-gray-700 dark:text-gray-300">Search</label>
|
||
|
|
<input type="text" name="q" value="{{ $q }}" placeholder="Search by title or slug" class="mt-1 w-full rounded-xl border-gray-300 dark:border-gray-700 bg-white/80 dark:bg-gray-900 text-gray-900 dark:text-gray-100 placeholder-gray-400 focus:border-indigo-500 focus:ring-indigo-500 px-3 py-2">
|
||
|
|
</div>
|
||
|
|
<div class="ml-auto">
|
||
|
|
<button type="submit" class="inline-flex items-center rounded-xl bg-indigo-600 px-4 py-2 text-sm font-semibold text-white shadow hover:bg-indigo-500">Apply</button>
|
||
|
|
</div>
|
||
|
|
</form>
|
||
|
|
|
||
|
|
<div class="overflow-hidden rounded-2xl ring-1 ring-gray-200 dark:ring-gray-700 bg-white dark:bg-gray-800">
|
||
|
|
<div class="overflow-x-auto">
|
||
|
|
<table class="min-w-full text-sm">
|
||
|
|
<thead class="bg-gray-50 dark:bg-gray-900/50">
|
||
|
|
<tr>
|
||
|
|
<th class="px-4 py-3 text-left font-semibold text-gray-700 dark:text-gray-300">Title</th>
|
||
|
|
<th class="px-4 py-3 text-left font-semibold text-gray-700 dark:text-gray-300">Slug</th>
|
||
|
|
<th class="px-4 py-3 text-left font-semibold text-gray-700 dark:text-gray-300">Status</th>
|
||
|
|
<th class="px-4 py-3 text-left font-semibold text-gray-700 dark:text-gray-300">Author</th>
|
||
|
|
<th class="px-4 py-3 text-right font-semibold text-gray-700 dark:text-gray-300">Actions</th>
|
||
|
|
</tr>
|
||
|
|
</thead>
|
||
|
|
<tbody class="divide-y divide-gray-200 dark:divide-gray-700">
|
||
|
|
@forelse($posts as $post)
|
||
|
|
<tr>
|
||
|
|
<td class="px-4 py-3 text-gray-900 dark:text-gray-100">{{ $post->title }}</td>
|
||
|
|
<td class="px-4 py-3 text-gray-600 dark:text-gray-300">{{ $post->slug }}</td>
|
||
|
|
<td class="px-4 py-3">
|
||
|
|
@if($post->is_published)
|
||
|
|
<span class="inline-flex items-center rounded-full bg-emerald-100 text-emerald-700 px-2.5 py-1 text-xs font-medium">Published</span>
|
||
|
|
@else
|
||
|
|
<span class="inline-flex items-center rounded-full bg-gray-100 text-gray-700 px-2.5 py-1 text-xs font-medium">Draft</span>
|
||
|
|
@endif
|
||
|
|
</td>
|
||
|
|
<td class="px-4 py-3 text-gray-600 dark:text-gray-300">{{ optional($post->author)->name ?? '—' }}</td>
|
||
|
|
<td class="px-4 py-3 text-right">
|
||
|
|
<a href="{{ route('admin.posts.edit', $post) }}" class="text-indigo-600 hover:text-indigo-500">Edit</a>
|
||
|
|
<form method="POST" action="{{ route('admin.posts.destroy', $post) }}" class="inline" onsubmit="return confirm('Delete this post?');">
|
||
|
|
@csrf
|
||
|
|
@method('DELETE')
|
||
|
|
<button type="submit" class="ms-3 text-red-600 hover:text-red-500">Delete</button>
|
||
|
|
</form>
|
||
|
|
</td>
|
||
|
|
</tr>
|
||
|
|
@empty
|
||
|
|
<tr><td colspan="5" class="px-4 py-6 text-center text-gray-600 dark:text-gray-300">No posts found.</td></tr>
|
||
|
|
@endforelse
|
||
|
|
</tbody>
|
||
|
|
</table>
|
||
|
|
</div>
|
||
|
|
<div class="px-4 py-3 border-t border-gray-100 dark:border-gray-800">
|
||
|
|
{{ $posts->links() }}
|
||
|
|
</div>
|
||
|
|
</div>
|
||
|
|
</section>
|
||
|
|
</x-app-layout>
|