1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Sco\Admin\Form; |
4
|
|
|
|
5
|
|
|
use Illuminate\Foundation\Application; |
6
|
|
|
use Sco\Admin\Contracts\Form\ElementFactoryInterface; |
7
|
|
|
use Sco\Admin\Form\Elements\Checkbox; |
8
|
|
|
use Sco\Admin\Form\Elements\Date; |
9
|
|
|
use Sco\Admin\Form\Elements\DateRange; |
10
|
|
|
use Sco\Admin\Form\Elements\DateTime; |
11
|
|
|
use Sco\Admin\Form\Elements\DateTimeRange; |
12
|
|
|
use Sco\Admin\Form\Elements\ElSwitch; |
13
|
|
|
use Sco\Admin\Form\Elements\Email; |
14
|
|
|
use Sco\Admin\Form\Elements\File; |
15
|
|
|
use Sco\Admin\Form\Elements\Hidden; |
16
|
|
|
use Sco\Admin\Form\Elements\Image; |
17
|
|
|
use Sco\Admin\Form\Elements\Images; |
18
|
|
|
use Sco\Admin\Form\Elements\Markdown; |
19
|
|
|
use Sco\Admin\Form\Elements\MultiSelect; |
20
|
|
|
use Sco\Admin\Form\Elements\Number; |
21
|
|
|
use Sco\Admin\Form\Elements\Password; |
22
|
|
|
use Sco\Admin\Form\Elements\Radio; |
23
|
|
|
use Sco\Admin\Form\Elements\Select; |
24
|
|
|
use Sco\Admin\Form\Elements\Text; |
25
|
|
|
use Sco\Admin\Form\Elements\Textarea; |
26
|
|
|
use Sco\Admin\Form\Elements\Time; |
27
|
|
|
use Sco\Admin\Form\Elements\Timestamp; |
28
|
|
|
use Sco\Admin\Form\Elements\Tinymce; |
29
|
|
|
use Sco\Admin\Form\Elements\Tree; |
30
|
|
|
use Sco\Admin\Traits\AliasBinder; |
31
|
|
|
|
32
|
|
|
/** |
33
|
|
|
* @method static Text text(string $name, string $title) |
34
|
|
|
* @method static Email email(string $name, string $title) |
35
|
|
|
* @method static Select select(string $name, string $title, $options = null) |
36
|
|
|
* @method static MultiSelect multiselect(string $name, string $title, $options = null) |
37
|
|
|
* @method static Tree tree(string $name, string $title, $nodes = null) |
38
|
|
|
* @method static Radio radio(string $name, string $title, $options = null) |
39
|
|
|
* @method static Checkbox checkbox(string $name, string $title, $options = null) |
40
|
|
|
* @method static Textarea textarea(string $name, string $title) |
41
|
|
|
* @method static Number number(string $name, string $title) |
42
|
|
|
* @method static Password password(string $name, string $title) |
43
|
|
|
* @method static File file(string $name, string $title) |
44
|
|
|
* @method static Image image(string $name, string $title) |
45
|
|
|
* @method static Images images(string $name, string $title) |
46
|
|
|
* @method static Hidden hidden($name) |
47
|
|
|
* @method static ElSwitch elswitch(string $name, string $title) |
48
|
|
|
* @method static Time time(string $name, string $title) |
49
|
|
|
* @method static Date date(string $name, string $title) |
50
|
|
|
* @method static DateTime datetime(string $name, string $title) |
51
|
|
|
* @method static Timestamp timestamp(string $name, string $title) |
52
|
|
|
* @method static DateRange daterange(string|array $name, string $title) |
53
|
|
|
* @method static DateTimeRange datetimerange(string|array $name, string $title) |
54
|
|
|
* @method static Tinymce tinymce(string $name, string $title) |
55
|
|
|
* @method static Markdown markdown(string $name, string $title) |
56
|
|
|
*/ |
57
|
|
|
class ElementFactory implements ElementFactoryInterface |
58
|
|
|
{ |
59
|
|
|
use AliasBinder; |
60
|
|
|
|
61
|
|
|
protected $app; |
62
|
|
|
|
63
|
|
|
public function __construct(Application $app) |
64
|
|
|
{ |
65
|
|
|
$this->app = $app; |
66
|
|
|
|
67
|
|
|
$this->register([ |
68
|
|
|
'text' => Text::class, |
69
|
|
|
'radio' => Radio::class, |
70
|
|
|
'checkbox' => Checkbox::class, |
71
|
|
|
'textarea' => Textarea::class, |
72
|
|
|
'select' => Select::class, |
73
|
|
|
'multiselect' => MultiSelect::class, |
74
|
|
|
'hidden' => Hidden::class, |
75
|
|
|
'number' => Number::class, |
76
|
|
|
'password' => Password::class, |
77
|
|
|
'email' => Email::class, |
78
|
|
|
'file' => File::class, |
79
|
|
|
'image' => Image::class, |
80
|
|
|
'images' => Images::class, |
81
|
|
|
'elswitch' => ElSwitch::class, |
82
|
|
|
'time' => Time::class, |
83
|
|
|
'date' => Date::class, |
84
|
|
|
'datetime' => DateTime::class, |
85
|
|
|
'timestamp' => Timestamp::class, |
86
|
|
|
'daterange' => DateRange::class, |
87
|
|
|
'datetimerange' => DateTimeRange::class, |
88
|
|
|
'tree' => Tree::class, |
89
|
|
|
'tinymce' => Tinymce::class, |
90
|
|
|
'markdown' => Markdown::class, |
91
|
|
|
]); |
92
|
|
|
} |
93
|
|
|
} |
94
|
|
|
|