|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Demo\Entities; |
|
4
|
|
|
|
|
5
|
|
|
use Psr\Http\Message\UploadedFileInterface; |
|
6
|
|
|
|
|
7
|
|
|
use Folk\Entities\Json; |
|
8
|
|
|
use FormManager\Builder; |
|
9
|
|
|
|
|
10
|
|
|
class Items extends Json |
|
11
|
|
|
{ |
|
12
|
|
|
public $icon = 'editor/insert_drive_file'; |
|
13
|
|
|
public $title = 'Items'; |
|
14
|
|
|
public $description = 'Random items'; |
|
15
|
|
|
|
|
16
|
|
|
protected function getBasePath() |
|
17
|
|
|
{ |
|
18
|
|
|
return __DIR__.'/json'; |
|
19
|
|
|
} |
|
20
|
|
|
|
|
21
|
|
|
public function create(array $data) |
|
22
|
|
|
{ |
|
23
|
|
|
if ($data['imageupload'] instanceof UploadedFileInterface) { |
|
24
|
|
|
$file = $data['imageupload']; |
|
25
|
|
|
$file->moveTo(__DIR__.'/img/'.$file->getClientFilename()); |
|
26
|
|
|
$data['imageupload'] = '/'.$file->getClientFilename(); |
|
27
|
|
|
} |
|
28
|
|
|
|
|
29
|
|
|
return parent::create($data); |
|
30
|
|
|
} |
|
31
|
|
|
|
|
32
|
|
|
public function getScheme(Builder $builder) |
|
33
|
|
|
{ |
|
34
|
|
|
return $builder->group([ |
|
35
|
|
|
'text' => $builder->text()->label('Title'), |
|
36
|
|
|
'checkbox' => $builder->checkbox()->label('Checkbox'), |
|
37
|
|
|
|
|
38
|
|
|
'choose' => $builder->choose([ |
|
39
|
|
|
1 => $builder->radio()->label('Radio 1'), |
|
40
|
|
|
2 => $builder->radio()->label('Radio 2'), |
|
41
|
|
|
])->label('Choose'), |
|
42
|
|
|
|
|
43
|
|
|
'code' => $builder->code()->label('Code'), |
|
44
|
|
|
|
|
45
|
|
|
'collection' => $builder->collection([ |
|
46
|
|
|
'text' => $builder->text()->label('Text'), |
|
47
|
|
|
'textarea' => $builder->textarea()->label('Textarea'), |
|
48
|
|
|
])->label('Collection'), |
|
49
|
|
|
|
|
50
|
|
|
'collectionMultiple' => $builder->collectionMultiple([ |
|
51
|
|
|
'text' => [ |
|
52
|
|
|
'text' => $builder->text()->label('Text'), |
|
53
|
|
|
'textarea' => $builder->textarea()->label('Textarea'), |
|
54
|
|
|
], |
|
55
|
|
|
'image' => [ |
|
56
|
|
|
'text' => $builder->imageUpload()->label('Image'), |
|
57
|
|
|
], |
|
58
|
|
|
])->label('Collection multiple'), |
|
59
|
|
|
|
|
60
|
|
|
'color' => $builder->color()->label('Color'), |
|
61
|
|
|
|
|
62
|
|
|
'date' => $builder->date()->label('Date'), |
|
63
|
|
|
|
|
64
|
|
|
'datetime' => $builder->datetime()->label('Datetime'), |
|
65
|
|
|
|
|
66
|
|
|
'datetimeLocal' => $builder->datetimeLocal()->label('Datetime local'), |
|
67
|
|
|
|
|
68
|
|
|
'email' => $builder->email()->label('Email'), |
|
69
|
|
|
|
|
70
|
|
|
'fileupload' => $builder->fileUpload()->label('File upload'), |
|
71
|
|
|
|
|
72
|
|
|
'html' => $builder->html()->label('Html'), |
|
73
|
|
|
|
|
74
|
|
|
'imageupload' => $builder->imageUpload() |
|
75
|
|
|
->data('config', [ |
|
76
|
|
|
'thumb' => 'Entities/img' |
|
77
|
|
|
]) |
|
78
|
|
|
->label('Image upload'), |
|
79
|
|
|
|
|
80
|
|
|
'info' => $builder->info()->label('Info'), |
|
81
|
|
|
|
|
82
|
|
|
'loader' => $builder->loader([ |
|
83
|
|
|
'field' => $builder->url()->label('Url'), |
|
84
|
|
|
'loader' => $builder->text()->label('Text'), |
|
85
|
|
|
])->label('Loader'), |
|
86
|
|
|
|
|
87
|
|
|
'month' => $builder->month()->label('Month'), |
|
88
|
|
|
|
|
89
|
|
|
'number' => $builder->number()->label('Number'), |
|
90
|
|
|
|
|
91
|
|
|
'password' => $builder->password()->label('Password'), |
|
92
|
|
|
|
|
93
|
|
|
'range' => $builder->range()->label('Range'), |
|
94
|
|
|
|
|
95
|
|
|
'select' => $builder->select([ |
|
96
|
|
|
1 => 'One', |
|
97
|
|
|
2 => 'Two', |
|
98
|
|
|
])->label('Select'), |
|
99
|
|
|
|
|
100
|
|
|
'table' => $builder->table()->label('Table'), |
|
101
|
|
|
|
|
102
|
|
|
'tel' => $builder->tel()->label('Tel'), |
|
103
|
|
|
|
|
104
|
|
|
'time' => $builder->time()->label('Time'), |
|
105
|
|
|
|
|
106
|
|
|
'url' => $builder->url()->label('Url'), |
|
107
|
|
|
|
|
108
|
|
|
'week' => $builder->week()->label('Week'), |
|
109
|
|
|
]); |
|
110
|
|
|
} |
|
111
|
|
|
} |
|
112
|
|
|
|