Completed
Push — master ( 425311...e07195 )
by Elf
01:49
created

EloquentDataTable::addColumn()   C

Complexity

Conditions 7
Paths 12

Size

Total Lines 23
Code Lines 12

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 56

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 23
ccs 0
cts 10
cp 0
rs 6.7272
cc 7
eloc 12
nc 12
nop 3
crap 56
1
<?php
2
3
namespace ElfSundae\Laravel\DataTables\Engines;
4
5
use Yajra\DataTables\EloquentDataTable as BaseEloquentDataTable;
6
7
class EloquentDataTable extends BaseEngine
8
{
9
    /**
10
     * Add column in collection.
11
     *
12
     * @param  string|string[]  $name
13
     * @param  string|callable|bool|int|null  $content
14
     * @param  bool|int  $order
15
     * @return $this
16
     */
17
    public function addColumn($name, $content = null, $order = false)
18
    {
19
        if (is_bool($content) || is_int($content)) {
20
            $order = $content;
21
            $content = null;
22
        }
23
24
        if (is_null($content) && is_string($name)) {
25
            $content = function ($model) use ($name) {
26
                return $model->{$name};
27
            };
28
        }
29
30
        if (is_array($name)) {
31
            foreach ($name as $n) {
32
                $this->addColumn($n, $content, $order);
33
            }
34
35
            return $this;
36
        }
37
38
        return parent::addColumn($name, $content, $order);
39
    }
40
}
41