80 lines
2.1 KiB
PHP
80 lines
2.1 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Http\Controllers\Bo;
|
|
|
|
use App\Http\Controllers\Controller;
|
|
use App\Models\ActivityLog;
|
|
use App\Traits\Controllers\ChangesModelOrder;
|
|
use App\Traits\Controllers\UpdateModelPublished;
|
|
use Illuminate\Contracts\View\View;
|
|
use Illuminate\Database\Eloquent\Builder;
|
|
use Illuminate\Http\Request;
|
|
|
|
class ActivityLogController extends Controller
|
|
{
|
|
use ChangesModelOrder;
|
|
use UpdateModelPublished;
|
|
|
|
/**
|
|
* Display a listing of the resource.
|
|
*/
|
|
public function index(Request $request): View
|
|
{
|
|
$this->authorize('isConceptor');
|
|
|
|
/** @var Builder $query */
|
|
$query = ActivityLog::query()->with('user');
|
|
|
|
/** @var string $search Search field */
|
|
$search = $request->search;
|
|
if ($search) {
|
|
$this->searchQuery(
|
|
$query,
|
|
$search,
|
|
null,
|
|
'model_class',
|
|
);
|
|
}
|
|
$searchFields = \implode(', ', [
|
|
trans('validation.custom.target'),
|
|
]);
|
|
|
|
/** Sort columns with a query */
|
|
$this->sortQuery($query);
|
|
|
|
/** Custom pagination */
|
|
$activitylogModels = $this->paginate($query);
|
|
|
|
/** @var view-string $view */
|
|
$view = 'back::pages.activity_logs.index';
|
|
|
|
return view($view, [
|
|
'activitylogModels' => $activitylogModels,
|
|
'search' => $search,
|
|
'searchFields' => $searchFields,
|
|
]);
|
|
}
|
|
|
|
/**
|
|
* Show the form for editing the specified resource.
|
|
*/
|
|
public function show(ActivityLog $activity_log): View
|
|
{
|
|
$this->authorize('isConceptor');
|
|
$targetModelClass = $activity_log->model_class;
|
|
$targetModel = $activity_log->model_class::where(
|
|
new $targetModelClass()->getRouteKeyName(),
|
|
$activity_log->model_id
|
|
)->first();
|
|
|
|
/** @var view-string $view */
|
|
$view = 'back::pages.activity_logs.show';
|
|
|
|
return view($view, [
|
|
'activitylogModel' => $activity_log,
|
|
'targetModel' => $targetModel,
|
|
]);
|
|
}
|
|
}
|