1 | <?php |
||
13 | trait UpdatesModelRelations |
||
14 | { |
||
15 | /** |
||
16 | * The model relationships that can be updated. |
||
17 | * |
||
18 | * @var array |
||
19 | */ |
||
20 | protected $fillableRelations = []; |
||
21 | |||
22 | /** |
||
23 | * Determine whether the given named relation can be updated on the model. |
||
24 | * |
||
25 | * @param string $relation |
||
26 | */ |
||
27 | protected function isFillableRelation(string $relation): bool |
||
31 | |||
32 | /** |
||
33 | * Determine the JSON API relation type for a named relation on the primary |
||
34 | * resource. |
||
35 | * |
||
36 | * @param string $relation |
||
37 | * |
||
38 | * @return string|void |
||
39 | */ |
||
40 | protected function getRelationType(string $relation) |
||
50 | |||
51 | /** |
||
52 | * Update a named many-to-one relationship association on a model instance. |
||
53 | * |
||
54 | * http://jsonapi.org/format/#crud-updating-to-one-relationships |
||
55 | * |
||
56 | * @param Model $record |
||
57 | * @param string $relation |
||
58 | * @param array $data |
||
59 | */ |
||
60 | protected function updateToOneResourceRelationship($record, string $relation, array $data) |
||
65 | |||
66 | /** |
||
67 | * Update named many-to-many relationship entries on a model instance. |
||
68 | * |
||
69 | * http://jsonapi.org/format/#crud-updating-to-many-relationships |
||
70 | * |
||
71 | * @param Model $record |
||
72 | * @param string $relation |
||
73 | * @param array $data |
||
74 | * @param string $method |
||
75 | */ |
||
76 | protected function updateToManyResourceRelationship($record, string $relation, array $data, string $method) |
||
99 | |||
100 | /** |
||
101 | * Update one or more relationships on a model instance from an array of |
||
102 | * named relationships and associated resource identifiers. |
||
103 | * |
||
104 | * http://jsonapi.org/format/#crud-updating-resource-relationships |
||
105 | * |
||
106 | * @param Model $record |
||
107 | * @param array $relationships |
||
108 | */ |
||
109 | protected function updateResourceRelationships($record, array $relationships) |
||
122 | } |
||
123 |
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion: