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