Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
0.00% covered (danger)
0.00%
0 / 26
0.00% covered (danger)
0.00%
0 / 2
CRAP
0.00% covered (danger)
0.00%
0 / 1
ActivityLogsController
0.00% covered (danger)
0.00%
0 / 26
0.00% covered (danger)
0.00%
0 / 2
12
0.00% covered (danger)
0.00%
0 / 1
 index
0.00% covered (danger)
0.00%
0 / 16
0.00% covered (danger)
0.00%
0 / 1
6
 show
0.00% covered (danger)
0.00%
0 / 10
0.00% covered (danger)
0.00%
0 / 1
2
1<?php
2
3namespace App\Http\Controllers\Bo;
4
5use App\Http\Controllers\Controller;
6use App\Models\ActivityLog;
7use App\Traits\Controllers\ChangesModelOrder;
8use App\Traits\Controllers\UpdateModelPublished;
9use Illuminate\Http\Request;
10
11class ActivityLogsController extends Controller
12{
13    use ChangesModelOrder;
14    use UpdateModelPublished;
15
16    /**
17     * Display a listing of the resource.
18     *
19     * @param \Illuminate\Http\Request $request
20     * @return \Illuminate\Contracts\View\View
21     */
22    public function index(Request $request): \Illuminate\Contracts\View\View
23    {
24        $this->authorize('isConceptor');
25        /** @var \Illuminate\Database\Eloquent\Builder $query */
26        $query = ActivityLog::query()->with('user');
27
28        /** @var string $search Search field */
29        $search = $request->search;
30        if ($search) {
31            $this->searchQuery(
32                $query,
33                $search,
34                null,
35                'model_class',
36            );
37        }
38        $searchFields = \implode(', ', [
39            trans('validation.custom.target'),
40        ]);
41
42        /** Sort columns with a query */
43        $this->sortQuery($query);
44
45        /** Custom pagination */
46        $activitylogModels = $this->paginate($query);
47
48        return view('bo.pages.activity_logs.index', compact('activitylogModels', 'search', 'searchFields'));
49    }
50
51    /**
52     * Show the form for editing the specified resource.
53     *
54     * @param App\Models\ActivityLog $activity_log
55     * @return \Illuminate\Contracts\View\View
56     */
57    public function show(ActivityLog $activity_log): \Illuminate\Contracts\View\View
58    {
59        $this->authorize('isConceptor');
60        $targetModelClass = $activity_log->model_class;
61        $targetModel      = $activity_log->model_class::where(
62            (new $targetModelClass())->getRouteKeyName(),
63            $activity_log->model_id
64        )->first();
65
66        return view('bo.pages.activity_logs.show', [
67            'activitylogModel' => $activity_log,
68            'targetModel'      => $targetModel,
69        ]);
70    }
71}