1 | <?php |
||
19 | trait HasLinksTrait |
||
20 | { |
||
21 | |||
22 | /** |
||
23 | * Add the links attribute to the model. |
||
24 | */ |
||
25 | public function initializeHasLinksTrait(): void |
||
26 | { |
||
27 | $this->append('_links'); |
||
28 | } |
||
29 | |||
30 | /** |
||
31 | * Append attributes to query when building a query. |
||
32 | * |
||
33 | * @param string[]|string $attributes |
||
34 | * @return $this |
||
35 | */ |
||
36 | abstract public function append($attributes); |
||
37 | |||
38 | /** |
||
39 | * Get the links for this model. |
||
40 | * @return mixed[] |
||
41 | * @throws ReflectionException |
||
42 | */ |
||
43 | public function getLinksAttribute(): array |
||
53 | |||
54 | /** |
||
55 | * Returns the _links for the REST responses. |
||
56 | * |
||
57 | * @return mixed[] |
||
58 | */ |
||
59 | public function buildLinks(): array |
||
77 | |||
78 | /** |
||
79 | * Builds the links to create the relationship resources. |
||
80 | * |
||
81 | * @return mixed[] |
||
82 | * @throws ReflectionException |
||
83 | */ |
||
84 | public function buildRelationshipLinks(): array |
||
130 | |||
131 | /** |
||
132 | * Return the name for the resource route this model |
||
133 | * @return string|null |
||
134 | */ |
||
135 | public function getRouteName(): ?string |
||
140 | |||
141 | |||
142 | /** |
||
143 | * Get the value of the model's route key. |
||
144 | * |
||
145 | * @return mixed |
||
146 | */ |
||
147 | public function getRouteKey() |
||
152 | } |
||
153 |