|
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\DatePickerField; |
|
9
|
|
|
use Webfactor\Laravel\Backpack\FluentSyntax\Fields\DateTimePickerField; |
|
10
|
|
|
use Webfactor\Laravel\Backpack\FluentSyntax\Fields\EmailField; |
|
11
|
|
|
use Webfactor\Laravel\Backpack\FluentSyntax\Fields\HiddenField; |
|
12
|
|
|
use Webfactor\Laravel\Backpack\FluentSyntax\Fields\NumberField; |
|
13
|
|
|
use Webfactor\Laravel\Backpack\FluentSyntax\Fields\PasswordField; |
|
14
|
|
|
use Webfactor\Laravel\Backpack\FluentSyntax\Fields\SummernoteField; |
|
15
|
|
|
use Webfactor\Laravel\Backpack\FluentSyntax\Fields\TextareaField; |
|
16
|
|
|
use Webfactor\Laravel\Backpack\FluentSyntax\Fields\TextField; |
|
17
|
|
|
use Webfactor\Laravel\Backpack\FluentSyntax\Fields\UrlField; |
|
18
|
|
|
|
|
19
|
|
|
trait FluentFields |
|
20
|
|
|
{ |
|
21
|
|
|
/* |
|
22
|
|
|
|-------------------------------------------------------------------------- |
|
23
|
|
|
| Methods for providing Fluent Fields |
|
24
|
|
|
|-------------------------------------------------------------------------- |
|
25
|
|
|
*/ |
|
26
|
|
|
|
|
27
|
|
|
public function addFields(array $fields) |
|
28
|
|
|
{ |
|
29
|
|
|
foreach ($fields as $field) { |
|
30
|
|
|
$this->addField($field); |
|
31
|
|
|
} |
|
32
|
|
|
} |
|
33
|
|
|
|
|
34
|
|
|
public function addField(CrudFieldInterface $field) |
|
|
|
|
|
|
35
|
|
|
{ |
|
36
|
|
|
return $this->crud->addField($field->make()); |
|
|
|
|
|
|
37
|
|
|
} |
|
38
|
|
|
|
|
39
|
|
|
/* |
|
40
|
|
|
|-------------------------------------------------------------------------- |
|
41
|
|
|
| Definition of all Field Types |
|
42
|
|
|
|-------------------------------------------------------------------------- |
|
43
|
|
|
*/ |
|
44
|
|
|
|
|
45
|
|
|
public function addressField(string $name): AddressField |
|
46
|
|
|
{ |
|
47
|
|
|
return new AddressField($name); |
|
48
|
|
|
} |
|
49
|
|
|
|
|
50
|
|
|
public function checkboxField(string $name): CheckboxField |
|
51
|
|
|
{ |
|
52
|
|
|
return new CheckboxField($name); |
|
53
|
|
|
} |
|
54
|
|
|
|
|
55
|
|
|
public function datePickerField(string $name): DatePickerField |
|
56
|
|
|
{ |
|
57
|
|
|
return new DatePickerField($name); |
|
58
|
|
|
} |
|
59
|
|
|
|
|
60
|
|
|
public function dateTimePickerField(string $name): DateTimePickerField |
|
61
|
|
|
{ |
|
62
|
|
|
return new DateTimePickerField($name); |
|
63
|
|
|
} |
|
64
|
|
|
|
|
65
|
|
|
public function emailField(string $name): EmailField |
|
66
|
|
|
{ |
|
67
|
|
|
return new EmailField($name); |
|
68
|
|
|
} |
|
69
|
|
|
|
|
70
|
|
|
public function hiddenField(string $name): HiddenField |
|
71
|
|
|
{ |
|
72
|
|
|
return new HiddenField($name); |
|
73
|
|
|
} |
|
74
|
|
|
|
|
75
|
|
|
public function numberField(string $name): NumberField |
|
76
|
|
|
{ |
|
77
|
|
|
return new NumberField($name); |
|
78
|
|
|
} |
|
79
|
|
|
|
|
80
|
|
|
public function passwordField(string $name): PasswordField |
|
81
|
|
|
{ |
|
82
|
|
|
return new PasswordField($name); |
|
83
|
|
|
} |
|
84
|
|
|
|
|
85
|
|
|
public function summernoteField(string $name): SummernoteField |
|
86
|
|
|
{ |
|
87
|
|
|
return new SummernoteField($name); |
|
88
|
|
|
} |
|
89
|
|
|
|
|
90
|
|
|
public function textareaField(string $name): TextareaField |
|
91
|
|
|
{ |
|
92
|
|
|
return new TextareaField($name); |
|
93
|
|
|
} |
|
94
|
|
|
|
|
95
|
|
|
public function textField(string $name): TextField |
|
96
|
|
|
{ |
|
97
|
|
|
return new TextField($name); |
|
98
|
|
|
} |
|
99
|
|
|
|
|
100
|
|
|
public function urlField(string $name): UrlField |
|
101
|
|
|
{ |
|
102
|
|
|
return new UrlField($name); |
|
103
|
|
|
} |
|
104
|
|
|
} |
|
105
|
|
|
|
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
@returnannotation as described here.