mirror of
https://github.com/BookStackApp/BookStack.git
synced 2024-08-25 19:56:05 +00:00
![Dan Brown](/assets/img/avatar_default.png)
Renamed some columns to be more generic and applicable. Removed now redundant book_id column. Allowed nullable entity morph columns for non-entity activity. Ran tests and made required changes.
57 lines
1.7 KiB
PHP
57 lines
1.7 KiB
PHP
<?php
|
|
|
|
namespace BookStack\Http\Controllers;
|
|
|
|
use BookStack\Actions\Activity;
|
|
use Illuminate\Http\Request;
|
|
use Illuminate\Support\Facades\DB;
|
|
|
|
class AuditLogController extends Controller
|
|
{
|
|
|
|
public function index(Request $request)
|
|
{
|
|
$this->checkPermission('settings-manage');
|
|
$this->checkPermission('users-manage');
|
|
|
|
$listDetails = [
|
|
'order' => $request->get('order', 'desc'),
|
|
'event' => $request->get('event', ''),
|
|
'sort' => $request->get('sort', 'created_at'),
|
|
'date_from' => $request->get('date_from', ''),
|
|
'date_to' => $request->get('date_to', ''),
|
|
];
|
|
|
|
$query = Activity::query()
|
|
->with([
|
|
'entity' => function ($query) {
|
|
$query->withTrashed();
|
|
},
|
|
'user'
|
|
])
|
|
->orderBy($listDetails['sort'], $listDetails['order']);
|
|
|
|
if ($listDetails['event']) {
|
|
$query->where('type', '=', $listDetails['event']);
|
|
}
|
|
|
|
if ($listDetails['date_from']) {
|
|
$query->where('created_at', '>=', $listDetails['date_from']);
|
|
}
|
|
if ($listDetails['date_to']) {
|
|
$query->where('created_at', '<=', $listDetails['date_to']);
|
|
}
|
|
|
|
$activities = $query->paginate(100);
|
|
$activities->appends($listDetails);
|
|
|
|
$types = DB::table('activities')->select('type')->distinct()->pluck('type');
|
|
$this->setPageTitle(trans('settings.audit'));
|
|
return view('settings.audit', [
|
|
'activities' => $activities,
|
|
'listDetails' => $listDetails,
|
|
'activityTypes' => $types,
|
|
]);
|
|
}
|
|
}
|