-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
22bafb5
commit 040f34b
Showing
16 changed files
with
298 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
<?php | ||
|
||
namespace App\Http\Controllers; | ||
|
||
use App\Models\ActivityLog; | ||
use Illuminate\Http\RedirectResponse; | ||
use Illuminate\Http\Request; | ||
use Illuminate\Support\Facades\Log; | ||
use Illuminate\View\View; | ||
|
||
class ActivityLogController extends Controller | ||
{ | ||
/** | ||
* Display a listing of the resource. | ||
*/ | ||
public function index(Request $request): View | ||
{ | ||
return view('pages.log.index', [ | ||
'items' => ActivityLog::query() | ||
->causedBy($request->user()) | ||
->search($request->query('q')) | ||
->render($request->query('size')), | ||
]); | ||
} | ||
|
||
/** | ||
* Remove the specified resource from storage. | ||
*/ | ||
public function destroy(ActivityLog $log): RedirectResponse | ||
{ | ||
try { | ||
$log->delete(); | ||
|
||
return back() | ||
->with('notification', $this->successNotification('notification.success_delete', 'menu.activity_log')); | ||
} catch (\Throwable $throwable) { | ||
Log::error($throwable->getMessage()); | ||
|
||
return back() | ||
->with('notification', $this->failNotification('notification.fail_delete', 'menu.activity_log')); | ||
} | ||
} | ||
|
||
public function destroyBulk(Request $request): RedirectResponse | ||
{ | ||
try { | ||
ActivityLog::query()->delete(); | ||
|
||
return back() | ||
->with('notification', $this->successNotification('notification.success_delete', 'menu.activity_log')); | ||
} catch (\Throwable $throwable) { | ||
Log::error($throwable->getMessage()); | ||
|
||
return back() | ||
->with('notification', $this->failNotification('notification.fail_delete', 'menu.activity_log')); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<?php | ||
|
||
namespace App\Models; | ||
|
||
use Illuminate\Database\Eloquent\Builder; | ||
use Illuminate\Database\Eloquent\Casts\Attribute; | ||
use Spatie\Activitylog\Models\Activity; | ||
|
||
class ActivityLog extends Activity | ||
{ | ||
protected $appends = [ | ||
'module' | ||
]; | ||
|
||
public function module(): Attribute | ||
{ | ||
return new Attribute( | ||
get: function () { | ||
$module = strtolower($this->log_name); | ||
$module = basename(str_replace("\\", "/", $module)); | ||
return __('menu.' . $module); | ||
} | ||
); | ||
} | ||
|
||
public function scopeSearch(Builder $query, ?string $search) | ||
{ | ||
return $query->when($search, function (Builder $query, string $search) { | ||
return $query | ||
->where('log_name', 'LIKE', $search.'%') | ||
->orWhere('subject', $search); | ||
}); | ||
} | ||
|
||
public function scopeRender(Builder $query, ?int $page): \Illuminate\Contracts\Pagination\LengthAwarePaginator | ||
{ | ||
return $query->latest()->paginate($page ?? 50)->withQueryString(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
<?php | ||
|
||
return [ | ||
|
||
/* | ||
* If set to false, no activities will be saved to the database. | ||
*/ | ||
'enabled' => env('ACTIVITY_LOGGER_ENABLED', true), | ||
|
||
/* | ||
* When the clean-command is executed, all recording activities older than | ||
* the number of days specified here will be deleted. | ||
*/ | ||
'delete_records_older_than_days' => 365, | ||
|
||
/* | ||
* If no log name is passed to the activity() helper | ||
* we use this default log name. | ||
*/ | ||
'default_log_name' => 'default', | ||
|
||
/* | ||
* You can specify an auth driver here that gets user models. | ||
* If this is null we'll use the current Laravel auth driver. | ||
*/ | ||
'default_auth_driver' => null, | ||
|
||
/* | ||
* If set to true, the subject returns soft deleted models. | ||
*/ | ||
'subject_returns_soft_deleted_models' => false, | ||
|
||
/* | ||
* This model will be used to log activity. | ||
* It should implement the Spatie\ActivityLog\Contracts\Activity interface | ||
* and extend Illuminate\Database\Eloquent\Model. | ||
*/ | ||
'activity_model' => \App\Models\ActivityLog::class, | ||
|
||
/* | ||
* This is the name of the table that will be created by the migration and | ||
* used by the Activity model shipped with this package. | ||
*/ | ||
'table_name' => env('ACTIVITY_LOGGER_TABLE_NAME', 'activity_log'), | ||
|
||
/* | ||
* This is the database connection that will be used by the migration and | ||
* the Activity model shipped with this package. In case it's not set | ||
* Laravel is database.default will be used instead. | ||
*/ | ||
'database_connection' => env('ACTIVITY_LOGGER_DB_CONNECTION'), | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<?php | ||
|
||
return [ | ||
'created' => 'Created new :menu <a class="link" target="_blank" href=":link">:identifier</a>.', | ||
'updated' => 'Updated :menu <a class="link" target="_blank" href=":link">:identifier</a>.', | ||
'deleted' => 'Deleted :menu :identifier.', | ||
'status-updated' => 'Updated :menu <a class="link" target="_blank" href=":link">:identifier</a>\'s status as <strong>:status</strong>.', | ||
'uploaded' => 'Uploaded new <strong>:file</strong> for :menu <a class="link" target="_blank" href=":link">:identifier</a>.', | ||
'delete-uploaded' => 'Deleted an uploaded <strong>:file</strong> for :menu <a class="link" target="_blank" href=":link">:identifier</a>.', | ||
'notary-office-accessed' => 'Notary Office <a class="link" target="_blank" href=":link">:identifier</a> accessed by administrator.', | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,5 +14,6 @@ | |
'import_feature' => 'Import :Feature', | ||
'delete' => 'Delete', | ||
'edit' => 'Edit', | ||
'delete_all' => 'Delete All', | ||
|
||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<?php | ||
|
||
return [ | ||
'created' => 'Membuat :menu <a class="link" target="_blank" href=":link">:identifier</a>.', | ||
'updated' => 'Memperbarui :menu <a class="link" target="_blank" href=":link">:identifier</a>.', | ||
'deleted' => 'Menghapus :menu :identifier.', | ||
'status-updated' => 'Mengubah status :menu <a class="link" target="_blank" href=":link">:identifier</a> menjadi <strong>:status</strong>.', | ||
'uploaded' => 'Mengunggah <strong>:file</strong> baru pada :menu <a class="link" target="_blank" href=":link">:identifier</a>.', | ||
'delete-uploaded' => 'Menghapus <strong>:file</strong> pada :menu <a class="link" target="_blank" href=":link">:identifier</a>.', | ||
'notary-office-accessed' => 'Kantor Notaris <a class="link" target="_blank" href=":link">:identifier</a> diakses oleh pengelola.', | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,5 +14,6 @@ | |
'import_feature' => 'Impor :Feature', | ||
'delete' => 'Hapus', | ||
'edit' => 'Edit', | ||
'delete_all' => 'Hapus Semua', | ||
|
||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
@extends('layouts.dashboard') | ||
|
||
@section('content') | ||
<div class="card"> | ||
<div class="card-header d-flex justify-content-between"> | ||
<h5>{{ __('menu.activity_log') }}</h5> | ||
<div> | ||
<form action="{{ route('account.log.destroy.bulk') }}" method="post" class="delete-form"> | ||
@csrf | ||
@method('DELETE') | ||
<button class="btn btn-danger"> | ||
{{ __('button.delete_all') }} | ||
</button> | ||
</form> | ||
</div> | ||
</div> | ||
<div class="table-responsive text-nowrap"> | ||
<table class="table"> | ||
<thead> | ||
<tr> | ||
<th>{{ __('field.timestamp') }}</th> | ||
<th>{{ __('field.module') }}</th> | ||
<th>{{ __('field.description') }}</th> | ||
<th style="width: 50px"></th> | ||
</tr> | ||
</thead> | ||
<tbody class="table-border-bottom-0"> | ||
@foreach($items as $item) | ||
<tr> | ||
<td>{{ $item->created_at }}</td> | ||
<td>{{ $item->module }}</td> | ||
<td>{!! $item->description !!}</td> | ||
<td> | ||
<div class="dropdown"> | ||
<button type="button" class="btn p-0 dropdown-toggle hide-arrow" data-bs-toggle="dropdown"><i class="bx bx-dots-vertical-rounded"></i></button> | ||
<div class="dropdown-menu"> | ||
<form action="{{ route('account.log.destroy', $item->id) }}" method="post" class="delete-form"> | ||
@csrf | ||
@method('DELETE') | ||
<button class="dropdown-item" type="submit"> | ||
<i class="bx bx-trash me-1"></i> | ||
{{ __('button.delete') }} | ||
</button> | ||
</form> | ||
</div> | ||
</div> | ||
</td> | ||
</tr> | ||
@endforeach | ||
</tbody> | ||
</table> | ||
</div> | ||
|
||
<div class="card-body"> | ||
{!! $items->links() !!} | ||
</div> | ||
</div> | ||
@endsection |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters