#2 create post
This commit is contained in:
70
resources/views/post/edit.blade.php
Normal file
70
resources/views/post/edit.blade.php
Normal file
@@ -0,0 +1,70 @@
|
||||
<x-app-layout>
|
||||
<x-slot name="header">
|
||||
<h2 class="font-semibold text-xl text-gray-800 leading-tight">
|
||||
{{ __('Edit Post') }}
|
||||
</h2>
|
||||
</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-updated')
|
||||
<div class="mb-4 rounded-md bg-green-50 px-4 py-3 text-sm text-green-700">
|
||||
{{ __('Post updated successfully.') }}
|
||||
</div>
|
||||
@endif
|
||||
|
||||
<form method="POST" action="{{ route('post.update', $post) }}" class="space-y-6 max-w-2xl">
|
||||
@csrf
|
||||
@method('patch')
|
||||
|
||||
<div>
|
||||
<x-input-label for="title" :value="__('Title')" />
|
||||
<x-text-input id="title" class="mt-1 block w-full" type="text" name="title" :value="old('title', $post->title)" required autofocus autocomplete="off" />
|
||||
<x-input-error class="mt-2" :messages="$errors->get('title')" />
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<x-input-label for="slug" :value="__('Slug')" />
|
||||
<x-text-input id="slug" class="mt-1 block w-full font-mono" type="text" name="slug" :value="old('slug', $post->slug)" required autocomplete="off" />
|
||||
<x-input-error class="mt-2" :messages="$errors->get('slug')" />
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<x-input-label for="content" :value="__('Content')" />
|
||||
<textarea
|
||||
id="content"
|
||||
name="content"
|
||||
rows="10"
|
||||
required
|
||||
class="mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500"
|
||||
>{{ old('content', $post->content) }}</textarea>
|
||||
<x-input-error class="mt-2" :messages="$errors->get('content')" />
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<x-input-label for="status" :value="__('Status')" />
|
||||
<select id="status" name="status" required class="mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500">
|
||||
@foreach (\App\Enums\PostStatus::cases() as $status)
|
||||
<option value="{{ $status->value }}" @selected(old('status', $post->status->value) === $status->value)>
|
||||
{{ $status->label() }}
|
||||
</option>
|
||||
@endforeach
|
||||
</select>
|
||||
<x-input-error class="mt-2" :messages="$errors->get('status')" />
|
||||
</div>
|
||||
|
||||
<div class="flex items-center gap-4">
|
||||
<x-primary-button>{{ __('Save') }}</x-primary-button>
|
||||
|
||||
<a href="{{ route('post.index') }}" class="text-sm text-gray-600 underline hover:text-gray-900">
|
||||
{{ __('Back') }}
|
||||
</a>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</x-app-layout>
|
||||
Reference in New Issue
Block a user