You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/docs/3.0/repository-pattern/field.md
+63-20Lines changed: 63 additions & 20 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,12 +1,10 @@
1
1
# Field
2
2
3
-
Field is basically the model attribute representation. Each Field generally extend the Field class from the Restify.
4
-
This class ships a variety of mutators, interceptors, validators chaining methods you can use for defining your attribute
5
-
according with your needed.
3
+
Field is basically the model attribute representation. Each Field generally extends the `Binaryk\LaravelRestify\Fields\Field` class from the Laravel Restify.
4
+
This class ships a variety of mutators, interceptors, validators chaining methods you can use for defining your attribute.
6
5
7
6
To add a field to a repository, we can simply add it to the repository's fields method.
8
-
Typically, fields may be created using their static make method. This method accepts the underlying database column as
9
-
argument:
7
+
Typically, fields may be created using their static `new` or `make` method. These methods accept the underlying database column as argument:
10
8
11
9
```php
12
10
@@ -21,10 +19,10 @@ use Binaryk\LaravelRestify\Http\Requests\RestifyRequest;
@@ -33,31 +31,31 @@ public function fields(RestifyRequest $request)
33
31
34
32
# Validation
35
33
36
-
There is a gold rule saying - catch the exception as soon as possible on it's request way.
34
+
There is a gold rule saying - catch the exception as soon as possible on its request way.
37
35
Validations are the first bridge of your request information, it would be a good start to validate
38
-
your input so you don't have to worry about payload anymore.
36
+
your input. So you don't have to worry about the payload anymore.
39
37
40
38
## Attaching rules
41
39
42
-
Validation rules could be add by chaining the `rules` method to attach [validation rules](https://laravel.com/docs/validation#available-validation-rules)
40
+
Validation rules could be adding by chaining the `rules` method to attach [validation rules](https://laravel.com/docs/validation#available-validation-rules)
43
41
to the field:
44
42
45
43
```php
46
-
Field::make('email')->rules('required'),
44
+
Field::new('email')->rules('required'),
47
45
```
48
46
49
47
Of course, if you are leveraging Laravel's support for [validation rule objects](https://laravel.com/docs/validation#using-rule-objects),
50
48
you may attach those to resources as well:
51
49
52
50
```php
53
-
Field::make('email')->rules('required', new CustomRule),
51
+
Field::new('email')->rules('required', new CustomRule),
54
52
```
55
53
56
54
Additionally, you may use [custom Closure rules](https://laravel.com/docs/validation#using-closures)
0 commit comments