1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Encore\Admin\Grid\Column; |
4
|
|
|
|
5
|
|
|
use Encore\Admin\Grid\Column; |
6
|
|
|
use Encore\Admin\Grid\Displayers; |
7
|
|
|
|
8
|
|
|
trait InlineEditing |
9
|
|
|
{ |
10
|
|
|
/** |
11
|
|
|
* @param string $selectable |
12
|
|
|
* |
13
|
|
|
* @return $this |
14
|
|
|
*/ |
15
|
|
View Code Duplication |
public function belongsTo($selectable) |
|
|
|
|
16
|
|
|
{ |
17
|
|
|
if (method_exists($selectable, 'display')) { |
18
|
|
|
$this->display($selectable::display()); |
|
|
|
|
19
|
|
|
} |
20
|
|
|
|
21
|
|
|
return $this->displayUsing(Displayers\BelongsTo::class, [$selectable]); |
|
|
|
|
22
|
|
|
} |
23
|
|
|
|
24
|
|
|
/** |
25
|
|
|
* @param string $selectable |
26
|
|
|
* |
27
|
|
|
* @return $this |
28
|
|
|
*/ |
29
|
|
View Code Duplication |
public function belongsToMany($selectable) |
|
|
|
|
30
|
|
|
{ |
31
|
|
|
if (method_exists($selectable, 'display')) { |
32
|
|
|
$this->display($selectable::display()); |
|
|
|
|
33
|
|
|
} |
34
|
|
|
|
35
|
|
|
return $this->displayUsing(Displayers\BelongsToMany::class, [$selectable]); |
|
|
|
|
36
|
|
|
} |
37
|
|
|
|
38
|
|
|
/** |
39
|
|
|
* Upload file. |
40
|
|
|
* |
41
|
|
|
* @return $this |
42
|
|
|
*/ |
43
|
|
|
public function upload() |
44
|
|
|
{ |
45
|
|
|
return $this->displayUsing(Displayers\Upload::class); |
|
|
|
|
46
|
|
|
} |
47
|
|
|
|
48
|
|
|
/** |
49
|
|
|
* Upload many files. |
50
|
|
|
* |
51
|
|
|
* @return $this |
52
|
|
|
*/ |
53
|
|
|
public function uplaodMany() |
54
|
|
|
{ |
55
|
|
|
return $this->displayUsing(Displayers\Upload::class, [true]); |
|
|
|
|
56
|
|
|
} |
57
|
|
|
|
58
|
|
|
/** |
59
|
|
|
* Grid inline datetime picker. |
60
|
|
|
* |
61
|
|
|
* @param string $format |
62
|
|
|
* |
63
|
|
|
* @return $this |
64
|
|
|
*/ |
65
|
|
|
public function datetime($format = 'YYYY-MM-DD HH:mm:ss') |
66
|
|
|
{ |
67
|
|
|
return $this->displayUsing(Displayers\Datetime::class, [$format]); |
|
|
|
|
68
|
|
|
} |
69
|
|
|
|
70
|
|
|
/** |
71
|
|
|
* Grid inline date picker. |
72
|
|
|
* |
73
|
|
|
* @param string $format |
|
|
|
|
74
|
|
|
* |
75
|
|
|
* @return $this |
76
|
|
|
*/ |
77
|
|
|
public function date() |
78
|
|
|
{ |
79
|
|
|
return $this->datetime('YYYY-MM-DD'); |
80
|
|
|
} |
81
|
|
|
|
82
|
|
|
/** |
83
|
|
|
* Grid inline time picker. |
84
|
|
|
* |
85
|
|
|
* @param string $format |
|
|
|
|
86
|
|
|
* |
87
|
|
|
* @return $this |
88
|
|
|
*/ |
89
|
|
|
public function time() |
90
|
|
|
{ |
91
|
|
|
return $this->datetime('HH:mm:ss'); |
92
|
|
|
} |
93
|
|
|
|
94
|
|
|
public function year() |
95
|
|
|
{ |
96
|
|
|
return $this->datetime('YYYY'); |
97
|
|
|
} |
98
|
|
|
|
99
|
|
|
public function month() |
100
|
|
|
{ |
101
|
|
|
return $this->datetime('MM'); |
102
|
|
|
} |
103
|
|
|
|
104
|
|
|
public function day() |
105
|
|
|
{ |
106
|
|
|
return $this->datetime('DD'); |
107
|
|
|
} |
108
|
|
|
|
109
|
|
|
public function input($mask = []) |
110
|
|
|
{ |
111
|
|
|
return $this->displayUsing(Displayers\Input::class, [$mask]); |
|
|
|
|
112
|
|
|
} |
113
|
|
|
|
114
|
|
|
public function ip() |
115
|
|
|
{ |
116
|
|
|
return $this->input(['alias' => 'ip']); |
117
|
|
|
} |
118
|
|
|
|
119
|
|
|
public function email() |
120
|
|
|
{ |
121
|
|
|
return $this->input(['alias' => 'email']); |
122
|
|
|
} |
123
|
|
|
} |
124
|
|
|
|
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.