добавлена кнопка удаления новости

This commit is contained in:
developer 2026-05-08 14:56:09 +08:00
parent d40abee083
commit 43cabbc7ea
2 changed files with 13 additions and 7 deletions

View File

@ -114,6 +114,6 @@ public function update(Request $request, Post $post)
public function delete(Post $post) public function delete(Post $post)
{ {
$post->delete(); $post->delete();
return to_route('admin.posts'); return back()->withSuccess('Новость удалена успешно');
} }
} }

View File

@ -21,11 +21,17 @@
@endif @endif
<div class="mt-2 d-flex justify-content-between align-items-center"> <div class="mt-2 d-flex justify-content-between align-items-center">
<h1 class="flex-fill">{{ $post->name }}</h1> <h1 class="flex-fill">{{ $post->name }}</h1>
<div class="ms-auto hstack gap-2">
@can('update', $post) @can('update', $post)
<div class="ms-auto">
@livewire('post.form', ['post' => $post]) @livewire('post.form', ['post' => $post])
</div>
@endcan @endcan
@can('delete', $post)
<form action="{{ route('admin.posts.delete', $post) }}" method="POST" onsubmit="return confirm('Вы уверены?')">
@csrf
<button type="submit" class="btn btn-danger"><i class="bi bi-x-lg"></i></button>
</form>
@endcan
</div>
</div> </div>
<p> <p>
{!! $post->trixRender('content') !!} {!! $post->trixRender('content') !!}