We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 6fe0bd6 commit 2b5381cCopy full SHA for 2b5381c
1 file changed
app/Commands/Concerns/InteractsWithIO.php
@@ -4,6 +4,7 @@
4
5
use Illuminate\Support\Collection;
6
use Illuminate\Support\Str;
7
+use SpinupWp\Resources\Resource;
8
use Symfony\Component\Console\Formatter\OutputFormatterStyle;
9
use Symfony\Component\Console\Helper\Table;
10
use Symfony\Component\Console\Question\ChoiceQuestion;
@@ -67,10 +68,14 @@ protected function displayFormat(): string
67
68
*/
69
protected function toJson($resource): void
70
{
- if (!is_array($resource)) {
71
+ if ($resource instanceof Resource) {
72
$resource = $resource->toArray();
73
}
74
75
+ if ($resource instanceof Collection) {
76
+ $resource = $resource->map(fn ($item) => $item instanceof Resource ? $item->toArray() : $item);
77
+ }
78
+
79
$this->line((string) json_encode($resource, JSON_PRETTY_PRINT));
80
81
0 commit comments