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 | * @return \Distilleries\Contentful\Models\Base\ContentfulModel|null |
||
139 | */ |
||
140 | protected function contentfulEntry($link): ?ContentfulModel |
||
153 | |||
154 | /** |
||
155 | * Return Contentful Entries for given ID. |
||
156 | * |
||
157 | * @param array $links |
||
158 | * @return \Illuminate\Support\Collection |
||
159 | */ |
||
160 | protected function contentfulEntries(array $links): Collection |
||
211 | |||
212 | /** |
||
213 | * Return a collection of related models for base Contentful ID. |
||
214 | * |
||
215 | * @param string $contentfulId |
||
216 | * @param string $contentfulType |
||
217 | * @return \Illuminate\Support\Collection |
||
218 | */ |
||
219 | protected function contentfulRelatedEntries(string $contentfulId, string $contentfulType = ''): Collection |
||
258 | |||
259 | /** |
||
260 | * Return Contentful link ID. |
||
261 | * |
||
262 | * @param mixed $link |
||
263 | * @return string|null |
||
264 | */ |
||
265 | protected function contentfulLinkId($link): ?string |
||
284 | |||
285 | public function getContentType(): string |
||
289 | } |
||
290 |
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.