1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Webfactor\Laravel\Backpack\FluentSyntax\Traits; |
4
|
|
|
|
5
|
|
|
use Webfactor\Laravel\Backpack\FluentSyntax\Contracts\CrudFieldInterface; |
6
|
|
|
use Webfactor\Laravel\Backpack\FluentSyntax\Fields\AddressField; |
7
|
|
|
use Webfactor\Laravel\Backpack\FluentSyntax\Fields\CheckboxField; |
8
|
|
|
use Webfactor\Laravel\Backpack\FluentSyntax\Fields\ColorPickerField; |
9
|
|
|
use Webfactor\Laravel\Backpack\FluentSyntax\Fields\DatePickerField; |
10
|
|
|
use Webfactor\Laravel\Backpack\FluentSyntax\Fields\DateRangeField; |
11
|
|
|
use Webfactor\Laravel\Backpack\FluentSyntax\Fields\DateTimePickerField; |
12
|
|
|
use Webfactor\Laravel\Backpack\FluentSyntax\Fields\EmailField; |
13
|
|
|
use Webfactor\Laravel\Backpack\FluentSyntax\Fields\EnumField; |
14
|
|
|
use Webfactor\Laravel\Backpack\FluentSyntax\Fields\HiddenField; |
15
|
|
|
use Webfactor\Laravel\Backpack\FluentSyntax\Fields\IconPickerField; |
16
|
|
|
use Webfactor\Laravel\Backpack\FluentSyntax\Fields\ImageField; |
17
|
|
|
use Webfactor\Laravel\Backpack\FluentSyntax\Fields\NumberField; |
18
|
|
|
use Webfactor\Laravel\Backpack\FluentSyntax\Fields\PasswordField; |
19
|
|
|
use Webfactor\Laravel\Backpack\FluentSyntax\Fields\SummernoteField; |
20
|
|
|
use Webfactor\Laravel\Backpack\FluentSyntax\Fields\TextareaField; |
21
|
|
|
use Webfactor\Laravel\Backpack\FluentSyntax\Fields\TextField; |
22
|
|
|
use Webfactor\Laravel\Backpack\FluentSyntax\Fields\UrlField; |
23
|
|
|
|
24
|
|
|
trait FluentFields |
25
|
|
|
{ |
26
|
|
|
/* |
27
|
|
|
|-------------------------------------------------------------------------- |
28
|
|
|
| Methods for providing Fluent Fields |
29
|
|
|
|-------------------------------------------------------------------------- |
30
|
|
|
*/ |
31
|
|
|
|
32
|
|
|
public function addFields(array $fields) |
33
|
|
|
{ |
34
|
|
|
foreach ($fields as $field) { |
35
|
|
|
$this->addField($field); |
36
|
|
|
} |
37
|
|
|
} |
38
|
|
|
|
39
|
|
|
public function addField(CrudFieldInterface $field) |
|
|
|
|
40
|
|
|
{ |
41
|
|
|
return $this->crud->addField($field->make()); |
|
|
|
|
42
|
|
|
} |
43
|
|
|
|
44
|
|
|
/* |
45
|
|
|
|-------------------------------------------------------------------------- |
46
|
|
|
| Definition of all Field Types |
47
|
|
|
|-------------------------------------------------------------------------- |
48
|
|
|
*/ |
49
|
|
|
|
50
|
|
|
public function addressField(string $name): AddressField |
51
|
|
|
{ |
52
|
|
|
return new AddressField($name); |
53
|
|
|
} |
54
|
|
|
|
55
|
|
|
public function checkboxField(string $name): CheckboxField |
56
|
|
|
{ |
57
|
|
|
return new CheckboxField($name); |
58
|
|
|
} |
59
|
|
|
|
60
|
|
|
public function colorPickerField(string $name): ColorPickerField |
61
|
|
|
{ |
62
|
|
|
return new ColorPickerField($name); |
63
|
|
|
} |
64
|
|
|
|
65
|
|
|
public function datePickerField(string $name): DatePickerField |
66
|
|
|
{ |
67
|
|
|
return new DatePickerField($name); |
68
|
|
|
} |
69
|
|
|
|
70
|
|
|
public function dateRangeField(string $uniqueName, string $startColumn, string $endColumn): DateRangeField |
71
|
|
|
{ |
72
|
|
|
return new DateRangeField($uniqueName, $startColumn, $endColumn); |
73
|
|
|
} |
74
|
|
|
|
75
|
|
|
public function dateTimePickerField(string $name): DateTimePickerField |
76
|
|
|
{ |
77
|
|
|
return new DateTimePickerField($name); |
78
|
|
|
} |
79
|
|
|
|
80
|
|
|
public function emailField(string $name): EmailField |
81
|
|
|
{ |
82
|
|
|
return new EmailField($name); |
83
|
|
|
} |
84
|
|
|
|
85
|
|
|
public function enumField(string $name): EnumField |
86
|
|
|
{ |
87
|
|
|
return new EnumField($name); |
88
|
|
|
} |
89
|
|
|
|
90
|
|
|
public function hiddenField(string $name): HiddenField |
91
|
|
|
{ |
92
|
|
|
return new HiddenField($name); |
93
|
|
|
} |
94
|
|
|
|
95
|
|
|
public function iconPickerField(string $name): IconPickerField |
96
|
|
|
{ |
97
|
|
|
return new IconPickerField($name); |
98
|
|
|
} |
99
|
|
|
|
100
|
|
|
public function ImageField(string $name): ImageField |
|
|
|
|
101
|
|
|
{ |
102
|
|
|
return new ImageField($name); |
103
|
|
|
} |
104
|
|
|
|
105
|
|
|
public function numberField(string $name): NumberField |
106
|
|
|
{ |
107
|
|
|
return new NumberField($name); |
108
|
|
|
} |
109
|
|
|
|
110
|
|
|
public function passwordField(string $name): PasswordField |
111
|
|
|
{ |
112
|
|
|
return new PasswordField($name); |
113
|
|
|
} |
114
|
|
|
|
115
|
|
|
public function summernoteField(string $name): SummernoteField |
116
|
|
|
{ |
117
|
|
|
return new SummernoteField($name); |
118
|
|
|
} |
119
|
|
|
|
120
|
|
|
public function textareaField(string $name): TextareaField |
121
|
|
|
{ |
122
|
|
|
return new TextareaField($name); |
123
|
|
|
} |
124
|
|
|
|
125
|
|
|
public function textField(string $name): TextField |
126
|
|
|
{ |
127
|
|
|
return new TextField($name); |
128
|
|
|
} |
129
|
|
|
|
130
|
|
|
public function urlField(string $name): UrlField |
131
|
|
|
{ |
132
|
|
|
return new UrlField($name); |
133
|
|
|
} |
134
|
|
|
} |
135
|
|
|
|
Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a
@return
annotation as described here.