Total Complexity | 5 |
Total Lines | 30 |
Duplicated Lines | 0 % |
Coverage | 100% |
Changes | 0 |
1 | <?php |
||
9 | trait JsonExporter |
||
10 | { |
||
11 | protected $jsonExportableRelations; |
||
12 | protected $jsonExportableAttributes; |
||
13 | |||
14 | 2 | public function exportToJson($jsonOptions = 0): string |
|
17 | } |
||
18 | |||
19 | 1 | public function exportToCollection(): Collection |
|
20 | { |
||
21 | 1 | return ExporterHelper::exportToCollection($this); |
|
22 | } |
||
23 | |||
24 | public function getJsonExportableAttributes(): array |
||
25 | { |
||
26 | 3 | return $this->jsonExportableAttributes ?? array_filter($this->getFillable(), function ($attribute) { |
|
27 | 3 | return !ends_with($attribute, '_id'); |
|
28 | 3 | }); |
|
29 | } |
||
30 | |||
31 | 2 | public function getJsonExportableRelations(): array |
|
32 | { |
||
33 | 2 | return $this->jsonExportableRelations ?? RelationsInModelFinder::hasOneOrMany($this); |
|
34 | } |
||
35 | |||
36 | 1 | public function isExporting(): bool |
|
39 | } |
||
40 | } |
||
41 |