1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Sco\Admin\Form\Elements; |
4
|
|
|
|
5
|
|
|
class File extends Element |
6
|
|
|
{ |
7
|
|
|
protected $type = 'file'; |
8
|
|
|
|
9
|
|
|
protected $actionUrl; |
10
|
|
|
|
11
|
|
|
protected $multiple = false; |
12
|
|
|
|
13
|
|
|
protected $showFileList = true; |
14
|
|
|
|
15
|
|
|
protected $withCredentials = false; |
16
|
|
|
|
17
|
|
|
public function getValue() |
18
|
|
|
{ |
19
|
|
|
$value = parent::getValue(); |
20
|
|
|
if (empty($value)) { |
21
|
|
|
return []; |
22
|
|
|
} |
23
|
|
|
|
24
|
|
|
return [ |
25
|
|
|
[ |
26
|
|
|
'name' => '', |
27
|
|
|
'url' => asset('vendor/admin/images/1200.jpg'), |
28
|
|
|
], |
29
|
|
|
]; |
30
|
|
|
} |
31
|
|
|
|
32
|
|
|
public function getActionUrl() |
33
|
|
|
{ |
34
|
|
|
if ($this->actionUrl) { |
35
|
|
|
return $this->actionUrl; |
36
|
|
|
} |
37
|
|
|
route('admin.dashboard'); |
38
|
|
|
} |
39
|
|
|
|
40
|
|
|
public function setActionUrl($value) |
41
|
|
|
{ |
42
|
|
|
$this->actionUrl = $value; |
43
|
|
|
|
44
|
|
|
return $this; |
45
|
|
|
} |
46
|
|
|
|
47
|
|
|
/** |
48
|
|
|
* Allow multiple selection files |
49
|
|
|
* |
50
|
|
|
* @return $this |
51
|
|
|
*/ |
52
|
|
|
public function isMultiple() |
53
|
|
|
{ |
54
|
|
|
$this->multiple = true; |
55
|
|
|
|
56
|
|
|
return $this; |
57
|
|
|
} |
58
|
|
|
|
59
|
|
|
/** |
60
|
|
|
* Do not show file list |
61
|
|
|
* |
62
|
|
|
* @return $this |
63
|
|
|
*/ |
64
|
|
|
public function hideFileList() |
65
|
|
|
{ |
66
|
|
|
$this->showFileList = true; |
67
|
|
|
|
68
|
|
|
return $this; |
69
|
|
|
} |
70
|
|
|
|
71
|
|
|
/** |
72
|
|
|
* Indicates whether or not cross-site Access-Control requests |
73
|
|
|
* should be made using credentials |
74
|
|
|
* |
75
|
|
|
* @return $this |
76
|
|
|
*/ |
77
|
|
|
public function withCredentials() |
78
|
|
|
{ |
79
|
|
|
$this->withCredentials = true; |
80
|
|
|
|
81
|
|
|
return $this; |
82
|
|
|
} |
83
|
|
|
|
84
|
|
|
public function setMaxSize($value) |
85
|
|
|
{ |
86
|
|
|
$this->addValidationRule('max:' . $value); |
|
|
|
|
87
|
|
|
|
88
|
|
|
return $this; |
89
|
|
|
} |
90
|
|
|
|
91
|
|
|
public function toArray() |
92
|
|
|
{ |
93
|
|
|
return parent::toArray() + [ |
94
|
|
|
'action' => $this->getActionUrl(), |
95
|
|
|
'showFileList' => $this->showFileList, |
96
|
|
|
'multiple' => $this->multiple, |
97
|
|
|
]; |
98
|
|
|
} |
99
|
|
|
} |
100
|
|
|
|
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.