Skip to content

Commit

Permalink
changes
Browse files Browse the repository at this point in the history
  • Loading branch information
davidvandertuijn committed Oct 5, 2024
1 parent 1fbe94c commit 5a4562a
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions src/app/Console/Commands/AfterSeeders/Make.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class Make extends Command
/**
* @var string
*/
protected $signature = 'after-seeders:make {table}';
protected $signature = 'after-seeders:make {table} {--tag=}';

/**
* @var string
Expand Down Expand Up @@ -150,19 +150,22 @@ protected function getFilename(string $table): string
*/
protected function getJson(\Illuminate\Support\Collection $records): string
{
$records = [];
// Initialize an array to hold the records
$data = [];

// Get the 'tag' option
$tag = $this->option('tag');

if (! empty($tag)) {
$records['TAG'] = $tag;
// Add the tag to the data array if it's not empty
if (!empty($tag)) {
$data['TAG'] = $tag;
}

$records = array_merge($records, [
'RECORDS' => $records->toArray(),
]);
// Convert the Collection to an array and merge it with the data array
$data['RECORDS'] = $records->toArray();

return json_encode($records, JSON_PRETTY_PRINT | JSON_HEX_TAG | JSON_HEX_AMP | JSON_HEX_APOS | JSON_HEX_QUOT);
// Encode the data as JSON
return json_encode($data, JSON_PRETTY_PRINT | JSON_HEX_TAG | JSON_HEX_AMP | JSON_HEX_APOS | JSON_HEX_QUOT);
}

/**
Expand Down

0 comments on commit 5a4562a

Please sign in to comment.