Passed
Push — master ( ab23d3...456c2a )
by Ferry
05:06
created

ColumnIntervention   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 17
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 6
c 1
b 0
f 0
dl 0
loc 17
rs 10
wmc 4

1 Method

Rating   Name   Duplication   Size   Complexity  
A columnIntervention() 0 11 4
1
<?php
2
/**
3
 * Created by PhpStorm.
4
 * User: User
5
 * Date: 8/15/2019
6
 * Time: 11:48 PM
7
 */
8
9
namespace crocodicstudio\crudbooster\controllers\traits;
10
11
use Illuminate\Support\Facades\Cache;
12
13
trait ColumnIntervention
14
{
15
    /**
16
     * ColumnIntervention method is to make additional custom column.
17
     * We can change the user column after cbInit() called.
18
     */
19
    public function columnIntervention()
20
    {
21
        if(request("sub_module") && Cache::has("subModule".request("sub_module")) && cb()->getCurrentMethod() != "getDetail") {
0 ignored issues
show
Bug introduced by
Are you sure request('sub_module') of type Illuminate\Http\Request|array|string can be used in concatenation? ( Ignorable by Annotation )

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

21
        if(request("sub_module") && Cache::has("subModule"./** @scrutinizer ignore-type */ request("sub_module")) && cb()->getCurrentMethod() != "getDetail") {
Loading history...
22
            /*
23
             * If there is sub module, the column that has same name with foreign key should be remove
24
             * And change to hidden. So we can save the foreign Key id from the parent module.
25
             */
26
            $subModule = Cache::get("subModule".request("sub_module"));
27
            $this->removeColumn($subModule["foreignKey"])
0 ignored issues
show
Bug introduced by
It seems like removeColumn() 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

27
            $this->/** @scrutinizer ignore-call */ 
28
                   removeColumn($subModule["foreignKey"])
Loading history...
28
                ->addHidden($subModule["foreignKey"],$subModule['foreignKey'])
29
                ->defaultValue($subModule['foreignValue']);
30
        }
31
    }
32
33
}