Passed
Pull Request — master (#1574)
by
unknown
06:56 queued 02:51
created

Hook::assignment()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 4
c 1
b 0
f 0
nc 2
nop 2
dl 0
loc 6
rs 10
1
<?php
2
/**
3
 * Created by PhpStorm.
4
 * User: User
5
 * Date: 2/13/2019
6
 * Time: 5:43 PM
7
 */
8
9
namespace crocodicstudio\crudbooster\types\date;
10
11
use crocodicstudio\crudbooster\types\TypesHook;
12
13
class Hook extends TypesHook
14
{
15
    /**
16
     * @param $row
17
     * @param $column DatetimeModel
0 ignored issues
show
Bug introduced by
The type crocodicstudio\crudboost...ypes\date\DatetimeModel was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
18
     * @return mixed
19
     */
20
    public function indexRender($row, $column)
21
    {
22
        if($column->getFormat()) {
23
            return date($column->getFormat(), strtotime($row->{$column->getField()}));
24
        }else{
25
            return $row->{$column->getField()};
26
        }
27
    }
28
29
    public function assignment($value, $column)
30
    {
31
		if($column->getFormat()) {
32
			return date_create_from_format($column->getFormat(), $value)->format('Y-m-d');
33
		} else {
34
			return $value;
35
		}
36
    }
37
    
38
    public function detailRender($row, $column)
39
    {
40
        return $this->indexRender($row, $column);
41
    }
42
43
    public function filterQuery($query, $column, $value)
44
    {
45
        $start = sanitizeXSS($value['start']);
46
        $end = sanitizeXSS($value['end']);
47
        if($start && $end) {
48
            $start = date("Y-m-d", strtotime($start));
49
            $end = date("Y-m-d", strtotime($end));
50
            $query->whereBetween($column->getFilterColumn(), [$start, $end]);
51
        }
52
        return $query;
53
    }
54
55
}
56