1 | <?php |
||
11 | abstract class ContentfulModel extends Model |
||
12 | { |
||
13 | use Localable; |
||
14 | |||
15 | /** |
||
16 | * {@inheritdoc} |
||
17 | */ |
||
18 | protected $primaryKey = 'contentful_id'; |
||
19 | |||
20 | /** |
||
21 | * The content Type id |
||
22 | * @var string |
||
23 | */ |
||
24 | protected $contentType = null; |
||
25 | |||
26 | |||
27 | /** |
||
28 | * {@inheritdoc} |
||
29 | */ |
||
30 | protected $keyType = 'string'; |
||
31 | |||
32 | /** |
||
33 | * {@inheritdoc} |
||
34 | */ |
||
35 | public $incrementing = false; |
||
36 | |||
37 | /** |
||
38 | * ContentfulModel constructor. |
||
39 | * |
||
40 | * @param array $attributes |
||
41 | * @return void |
||
|
|||
42 | */ |
||
43 | public function __construct(array $attributes = []) |
||
67 | |||
68 | protected function initContentType() |
||
75 | |||
76 | /** |
||
77 | * Return default fillable fields. |
||
78 | * |
||
79 | * @return array |
||
80 | */ |
||
81 | public function defaultFillable(): array |
||
92 | |||
93 | /** |
||
94 | * Return default casted fields. |
||
95 | * |
||
96 | * @return array |
||
97 | */ |
||
98 | public function defaultCasts(): array |
||
104 | |||
105 | |||
106 | // -------------------------------------------------------------------------------- |
||
107 | // -------------------------------------------------------------------------------- |
||
108 | // -------------------------------------------------------------------------------- |
||
109 | |||
110 | /** |
||
111 | * Return Contentful Asset for given link (sys or ID). |
||
112 | * |
||
113 | * @param array|string|null $link |
||
114 | * @return \Distilleries\Contentful\Models\Asset|null |
||
115 | */ |
||
116 | protected function contentfulAsset($link): ?Asset |
||
133 | |||
134 | /** |
||
135 | * Return Contentful Entry for given link (sys or ID). |
||
136 | * |
||
137 | * @param array|string|null $link |
||
138 | * @param callback|null $query |
||
139 | * @return \Distilleries\Contentful\Models\Base\ContentfulModel|null |
||
140 | */ |
||
141 | protected function contentfulEntry($link, $query = null): ?ContentfulModel |
||
154 | |||
155 | /** |
||
156 | * Return Contentful Entries for given ID. |
||
157 | * |
||
158 | * @param array $links |
||
159 | * @param callback|null $query |
||
160 | * @return \Illuminate\Support\Collection |
||
161 | */ |
||
162 | protected function contentfulEntries(array $links, $query = null): Collection |
||
220 | |||
221 | /** |
||
222 | * Return a collection of related models for base Contentful ID. |
||
223 | * |
||
224 | * @param string $contentfulId |
||
225 | * @param string $contentfulType |
||
226 | * @return \Illuminate\Support\Collection |
||
227 | */ |
||
228 | protected function contentfulRelatedEntries(string $contentfulId, string $contentfulType = ''): Collection |
||
267 | |||
268 | /** |
||
269 | * Return Contentful link ID. |
||
270 | * |
||
271 | * @param mixed $link |
||
272 | * @return string|null |
||
273 | */ |
||
274 | protected function contentfulLinkId($link): ?string |
||
293 | |||
294 | public function getContentType(): string |
||
298 | |||
299 | public function getIdAttribute() |
||
303 | |||
304 | public function toArray() |
||
316 | |||
317 | } |
||
318 |
Adding a
@return
annotation to a constructor is not recommended, since a constructor does not have a meaningful return value.Please refer to the PHP core documentation on constructors.