fix: update comment management

This commit is contained in:
2026-08-19 08:17:06 +03:30
parent 552b23d5ff
commit 97c01a17a3
5 changed files with 142 additions and 15 deletions
+82 -3
View File
@@ -1,3 +1,82 @@
<div>
<!-- Because you are alive, everything is possible. - Thich Nhat Hanh -->
</div>
@extends('admin.layouts.app')
@section('title', 'مدیریت نظرات')
@section('content')
<div class="container-fluid py-4">
<div class="d-flex justify-content-between align-items-center mb-4">
<h4 class="mb-0">مدیریت نظرات</h4>
<span class="badge text-bg-primary">{{ $comments->total() }} نظر</span>
</div>
@if (session('success'))
<div class="alert alert-success alert-dismissible fade show" role="alert">
{{ session('success') }}
<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="بستن"></button>
</div>
@endif
<div class="card shadow-sm">
<div class="table-responsive">
<table class="table table-hover align-middle mb-0">
<thead class="table-light">
<tr>
<th>#</th>
<th>کاربر</th>
<th>مرتبط با</th>
<th>متن نظر</th>
<th>وضعیت</th>
<th>تاریخ</th>
<th class="text-center">عملیات</th>
</tr>
</thead>
<tbody>
@forelse ($comments as $comment)
<tr>
<td>{{ $comments->firstItem() + $loop->index }}</td>
<td>{{ $comment->user?->name ?? 'کاربر حذف‌شده' }}</td>
<td>
<span
class="d-block text-muted small">{{ class_basename($comment->commentable_type) }}</span>
<span class="small">شناسه: {{ $comment->commentable_id }}</span>
</td>
<td class="text-truncate" style="max-width: 250px;">
{{ \Illuminate\Support\Str::limit($comment->body, 60) }}
</td>
<td>
@include('admin.comments.status', ['status' => $comment->status])
</td>
<td class="small text-muted">{{ $comment->created_at->format('Y/m/d') }}</td>
<td class="text-center">
<div class="btn-group btn-group-sm" role="group">
<a href="{{ route('admin.comments.show', $comment) }}"
class="btn btn-outline-secondary" title="نمایش">نمایش</a>
<a href="{{ route('admin.comments.edit', $comment) }}"
class="btn btn-outline-primary" title="ویرایش">ویرایش</a>
<form action="{{ route('admin.comments.destroy', $comment) }}" method="POST"
class="d-inline"
onsubmit="return confirm('نظر حذف شود؟')">
@csrf
@method('DELETE')
<button type="submit" class="btn btn-outline-danger" title="حذف">حذف</button>
</form>
</div>
</td>
</tr>
@empty
<tr>
<td colspan="7" class="text-center text-muted py-4">هنوز نظری ثبت نشده است.</td>
</tr>
@endforelse
</tbody>
</table>
</div>
</div>
<div class="mt-3">
{{ $comments->links() }}
</div>
</div>
@endsection