fix : complete Activity log in admin side

This commit is contained in:
2026-08-20 14:51:46 -07:00
parent 6ecb9b2704
commit 88503595d7
14 changed files with 316 additions and 223 deletions
@@ -1,3 +1,107 @@
@extends('admin.layouts.app')
@section('breadcrumb')<div><h1 class="page-title fw-medium fs-18 mb-1">لاگ تغییرات</h1><span class="text-muted fs-12">ثبت چه کسی، چه زمانی و چه تغییری روی اطلاعات پرواز و تور</span></div>@endsection
@section('content')<div class="container-fluid pt-4"><div class="card custom-card"><div class="card-body"><form method="GET"><div class="row g-2"><div class="col-md-4"><input class="form-control" name="search" value="{{ request('search') }}" placeholder="جستجو در توضیحات"></div><div class="col-md-3"><select class="form-control" name="subject_type"><option value="">همه بخش‌ها</option><option value="flight" @selected(request('subject_type')==='flight')>پرواز</option><option value="tour" @selected(request('subject_type')==='tour')>تور</option></select></div><div class="col-md-2"><button class="btn btn-light w-100">جستجو</button></div></div></form></div></div><div class="card custom-card mt-3"><div class="table-responsive"><table class="table text-nowrap"><thead><tr><th>مدیر</th><th>بخش</th><th>عملیات</th><th>شرح تغییر</th><th>تاریخ</th></tr></thead><tbody>@forelse(($logs ?? []) as $log)<tr><td>{{ $log->admin->first_name ?? '-' }} {{ $log->admin->last_name ?? '' }}</td><td>{{ $log->subject_type ?? '-' }}</td><td>{{ $log->action ?? '-' }}</td><td>{{ $log->description ?? '-' }}</td><td>{{ isset($log->created_at) ? $log->created_at->toJalali()->format('Y/m/d H:i') : '-' }}</td></tr>@empty<tr><td colspan="5" class="text-center text-muted py-5">لاگی برای نمایش وجود ندارد.</td></tr>@endforelse</tbody></table></div></div>{{ ($logs ?? collect())->links() }}</div>@endsection
@section('content')
<div class="container-fluid pt-4">
<div class="row">
<div class="col-xl-12">
<div class="card custom-card">
<div class="card-header">
<div class="card-title">
لاگ تغییرات پرواز و تور
</div>
</div>
<div class="card-body pt-0">
<div class="table-responsive">
<table class="table text-nowrap">
<thead>
<tr>
<th>کاربر</th>
<th>عملیات</th>
<th>مربوط به</th>
<th>تغییرات</th>
<th>زمان</th>
</tr>
</thead>
<tbody>
@forelse($logs as $log)
<tr>
<td>
{{ optional($log->causer)->first_name ?? 'نامشخص' }}
</td>
<td>
@switch($log->event)
@case('created')
<span class="badge bg-success-transparent">ایجاد</span>
@break
@case('updated')
<span class="badge bg-warning-transparent">ویرایش</span>
@break
@case('deleted')
<span class="badge bg-danger-transparent">حذف</span>
@break
@default
{{ $log->event }}
@endswitch
</td>
<td>
{{ $log->log_name === 'flights' ? 'پرواز' : 'تور' }}
#{{ $log->subject_id }}
</td>
<td>
@if($log->event === 'updated' && $log->changes)
<ul class="mb-0 ps-3">
@foreach($log->changes['after'] as $field => $newValue)
@if(($log->changes['before'][$field] ?? null) != $newValue)
<li>
{{ $field }}:
«{{ $log->changes['before'][$field] ?? '—' }}»
&larr;
«{{ $newValue }}»
</li>
@endif
@endforeach
</ul>
@elseif($log->event === 'created')
ایجاد رکورد جدید
@else
حذف رکورد
@endif
</td>
<td>
{{ verta($log->created_at)->format('Y/m/d H:i') }}
</td>
</tr>
@empty
<tr>
<td colspan="5" class="text-center">
لاگی ثبت نشده است
</td>
</tr>
@endforelse
</tbody>
</table>
</div>
{{ $logs->links() }}
</div>
</div>
</div>
</div>
</div>
@endsection
@@ -1,141 +0,0 @@
@extends('admin.layouts.app')
@section('content')
<div class="main-content app-content">
<div class="container-fluid pt-4">
<div class="row">
<div class="col-xl-12">
<form action="{{ route('admin.product.store') }}" method="POST" enctype="multipart/form-data">
@csrf
@error('general')
<span class="text-danger">{{ $message }}</span>
@enderror
<div class="card custom-card">
<div class="card-header">
<div class="card-title">
ایجاد محصول
</div>
</div>
<div class="card-body pt-0">
<div class="row gy-3">
<!-- Name -->
<div class="col-xl-6">
<label class="form-label">نام فارسی</label>
<input
type="text"
class="form-control" name="name"
placeholder="نام فارسی را وارد کنید"
value="{{ old('name') }}"
/>
@error('name')
<span class="text-danger">{{ $message }}</span>
@enderror
</div>
<!-- Name -->
<div class="col-xl-6">
<label class="form-label">نام انگلیسی</label>
<input type="text" class="form-control" name="en_name"
placeholder="نام انگلیسی را وارد کنید" value="{{ old('en_name') }}">
@error('en_name')
<span class="text-danger">{{ $message }}</span>
@enderror
</div>
<!-- Category -->
<div class="col-xl-6">
<label class="form-label">دسته‌ بندی</label>
<select class="form-control" name="category_id">
<option>یک دسته بندی انتخاب کنید</option>
@foreach($productCategories as $productCategory)
<option value="{{ $productCategory->id }}" >
{{ $productCategory->name }}
</option>
@endforeach
</select>
</div>
<!-- Price -->
<div class="col-xl-6">
<label class="form-label">قیمت</label>
<input type="number" class="form-control" name="price"
placeholder="قیمت را وارد کنید" value="{{old('price')}}">
@error('price')
<span class="text-danger">{{ $message }}</span>
@enderror
</div>
<!-- Discount Price -->
<div class="col-xl-6">
<label class="form-label">تخفیف</label>
<input type="number" class="form-control" name="discount"
placeholder="تخفیف را وارد کنید"
value="{{ old('discount') }}">
@error('discount')
<span class="text-danger">{{ $message }}</span>
@enderror
</div>
<!-- Stock -->
<div class="col-xl-6">
<label class="form-label">موجودی</label>
<input type="number" class="form-control" name="qty"
placeholder="تعداد موجودی را وارد کنید" value="{{ old('qty') }}">
@error('qty')
<span class="text-danger">{{ $message }}</span>
@enderror
</div>
<!-- Description -->
<div class="col-xl-12">
<label class="form-label">توضیحات</label>
<textarea class="form-control" name="description" rows="4"
placeholder="توضیحات را وارد کنید">{{ old('description') }}</textarea>
@error('description')
<span class="text-danger">{{ $message }}</span>
@enderror
</div>
</div>
<!-- Product Images -->
<div
class="image-upload-wrapper d-flex flex-wrap gap-2 px-0 pt-0 mt-3"
id="imagePreviewContainer"
style=" border-radius: 8px; padding: 10px;"
>
<label
id="uploadPlaceholder"
class="upload-placeholder"
for="imageInput"
style="cursor: pointer; width:150px; height:150px; display: flex; justify-content: center; align-items: center; border: 2px dashed #ccc; border-radius: 8px; padding: 20px; text-align: center;"
>
<div>📷<br><strong>آپلود یا کشیدن</strong></div>
<small style="color:#999;">JPG / PNG / JPEG / WEBP</small>
</label>
<input
id="imageInput"
name="images[]"
type="file"
accept=".jpg,.png,.jpeg,.webp"
multiple
style="display:none"
/>
</div>
</div>
<div class="card-footer text-end">
<button type="submit" class="btn btn-primary">ایجاد محصول</button>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
@endsection