LogFilesController   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
eloc 13
c 1
b 0
f 0
dl 0
loc 30
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A __invoke() 0 23 3
1
<?php
2
3
namespace App\Http\Controllers\Admin\Logs;
4
5
use Inertia\Inertia;
6
7
use Illuminate\Support\Arr;
8
9
use App\Models\AppSettings;
10
use App\Traits\LogUtilitiesTrait;
11
use App\Http\Controllers\Controller;
12
13
class LogFilesController extends Controller
14
{
15
    use LogUtilitiesTrait;
16
17
    /**
18
     *  View a list of log files
19
     */
20
    public function __invoke($channel = null)
21
    {
22
        $this->authorize('viewAny', AppSettings::class);
23
24
        $props = [];
25
        if(!is_null($channel))
26
        {
27
            //  If the channel name is invalid, return 404 error
28
            if(is_null($this->getChannelDetails($channel)))
29
            {
30
                abort(404, 'Cannot find the specified Log Channel');
31
            }
32
33
            $props = [
34
                'channel'   => $channel,
35
                'log_files' => $this->getChannelStats($channel),
36
                'levels'    => $this->logLevels,
37
            ];
38
        }
39
40
        $props['channels'] = Arr::pluck($this->logChannels, 'name');
41
42
        return Inertia::render('Logs/Index', $props);
43
    }
44
}
45