#2 create post
This commit is contained in:
89
resources/views/post/index.blade.php
Normal file
89
resources/views/post/index.blade.php
Normal file
@@ -0,0 +1,89 @@
|
||||
<x-app-layout>
|
||||
<x-slot name="header">
|
||||
<div class="flex items-center justify-between">
|
||||
<h2 class="font-semibold text-xl text-gray-800 leading-tight">
|
||||
{{ __('My Posts') }}
|
||||
</h2>
|
||||
<a href="{{ route('post.create') }}" class="inline-flex items-center px-4 py-2 bg-indigo-600 border border-transparent rounded-md font-semibold text-xs text-white uppercase tracking-widest hover:bg-indigo-500 focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:ring-offset-2 transition ease-in-out duration-150">
|
||||
{{ __('New Post') }}
|
||||
</a>
|
||||
</div>
|
||||
</x-slot>
|
||||
|
||||
<div class="py-12">
|
||||
<div class="max-w-7xl mx-auto sm:px-6 lg:px-8">
|
||||
<div class="bg-white overflow-hidden shadow-sm sm:rounded-lg">
|
||||
<div class="p-6 text-gray-900">
|
||||
@if (session('status') === 'post-created')
|
||||
<div class="mb-4 rounded-md bg-green-50 px-4 py-3 text-sm text-green-700">
|
||||
{{ __('Post created successfully.') }}
|
||||
</div>
|
||||
@endif
|
||||
|
||||
@if (session('status') === 'post-deleted')
|
||||
<div class="mb-4 rounded-md bg-green-50 px-4 py-3 text-sm text-green-700">
|
||||
{{ __('Post deleted successfully.') }}
|
||||
</div>
|
||||
@endif
|
||||
|
||||
<div class="overflow-x-auto">
|
||||
<table class="min-w-full divide-y divide-gray-200">
|
||||
<thead class="bg-gray-50">
|
||||
<tr>
|
||||
<th scope="col" class="px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">{{ __('Title') }}</th>
|
||||
<th scope="col" class="px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">{{ __('Slug') }}</th>
|
||||
<th scope="col" class="px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">{{ __('Status') }}</th>
|
||||
<th scope="col" class="px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">{{ __('Created') }}</th>
|
||||
<th scope="col" class="px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">{{ __('Actions') }}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody class="divide-y divide-gray-200">
|
||||
@forelse ($posts as $post)
|
||||
<tr class="odd:bg-white even:bg-gray-50">
|
||||
<td class="px-4 py-3 text-sm text-gray-900 max-w-xs truncate">{{ $post->title }}</td>
|
||||
<td class="px-4 py-3 text-sm text-gray-500 font-mono">{{ $post->slug }}</td>
|
||||
<td class="px-4 py-3 text-sm">
|
||||
<span @class([
|
||||
'inline-flex items-center rounded-full px-2.5 py-0.5 text-xs font-medium',
|
||||
'bg-green-100 text-green-800' => $post->status->value === 'published',
|
||||
'bg-yellow-100 text-yellow-800' => $post->status->value === 'draft',
|
||||
])>
|
||||
{{ $post->status->label() }}
|
||||
</span>
|
||||
</td>
|
||||
<td class="px-4 py-3 text-sm text-gray-700">{{ $post->created_at?->format('Y-m-d H:i') }}</td>
|
||||
<td class="px-4 py-3 text-sm text-gray-700">
|
||||
<div class="flex items-center gap-3">
|
||||
<a href="{{ route('post.edit', $post) }}" class="font-medium text-indigo-600 hover:text-indigo-500">
|
||||
{{ __('Edit') }}
|
||||
</a>
|
||||
<form method="POST" action="{{ route('post.destroy', $post) }}" onsubmit="return confirm('{{ __('Delete this post?') }}')">
|
||||
@csrf
|
||||
@method('DELETE')
|
||||
<button type="submit" class="font-medium text-red-600 hover:text-red-500">
|
||||
{{ __('Delete') }}
|
||||
</button>
|
||||
</form>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
@empty
|
||||
<tr>
|
||||
<td colspan="5" class="px-4 py-6 text-sm text-center text-gray-500">
|
||||
{{ __('No posts yet.') }}
|
||||
<a href="{{ route('post.create') }}" class="text-indigo-600 hover:text-indigo-500">{{ __('Create your first post.') }}</a>
|
||||
</td>
|
||||
</tr>
|
||||
@endforelse
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<div class="mt-6">
|
||||
{{ $posts->links() }}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</x-app-layout>
|
||||
Reference in New Issue
Block a user