Passed
Push — master ( 290de6...0c211d )
by Carlos
04:41
created

LogAuditTrait::createViewLogAudit()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 13
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 7
dl 0
loc 13
rs 10
c 1
b 0
f 0
cc 1
nc 1
nop 1
1
<?php
2
/**
3
 * This file is part of FacturaScripts
4
 * Copyright (C) 2021 Carlos Garcia Gomez <[email protected]>
5
 *
6
 * This program is free software: you can redistribute it and/or modify
7
 * it under the terms of the GNU Lesser General Public License as
8
 * published by the Free Software Foundation, either version 3 of the
9
 * License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
 * GNU Lesser General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU Lesser General Public License
17
 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18
 */
19
20
namespace FacturaScripts\Core\Lib\ExtendedController;
21
22
use FacturaScripts\Core\Base\DataBase\DataBaseWhere;
23
24
trait LogAuditTrait
25
{
26
    public function createViewLogAudit(string $viewName = 'ListLogMessage')
27
    {
28
        $this->addListView($viewName, 'LogMessage', 'history', 'fas fa-history');
0 ignored issues
show
Bug introduced by
It seems like addListView() must be provided by classes using this trait. How about adding it as abstract method to this trait? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

28
        $this->/** @scrutinizer ignore-call */ 
29
               addListView($viewName, 'LogMessage', 'history', 'fas fa-history');
Loading history...
29
        $this->views[$viewName]->addOrderBy(['time'], 'date', 2);
30
        $this->views[$viewName]->addSearchFields(['message', 'original']);
31
32
        // disable columns
33
        $this->views[$viewName]->disableColumn('channel');
34
        $this->views[$viewName]->disableColumn('url');
35
36
        // disable buttons
37
        $this->setSettings($viewName, 'btnDelete', false);
0 ignored issues
show
Bug introduced by
It seems like setSettings() must be provided by classes using this trait. How about adding it as abstract method to this trait? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

37
        $this->/** @scrutinizer ignore-call */ 
38
               setSettings($viewName, 'btnDelete', false);
Loading history...
38
        $this->setSettings($viewName, 'btnNew', false);
39
    }
40
41
    public function loadDataLogAudit($view, $model, $modelid)
42
    {
43
        $where = [
44
            new DataBaseWhere('model', $model),
45
            new DataBaseWhere('modelcode', $modelid)
46
        ];
47
        $view->loadData('', $where);
48
    }
49
}
50