Add CLI audit command docs
This commit is contained in:
36
app/Console/Commands/CheckArtworkUserIdsCommand.php
Normal file
36
app/Console/Commands/CheckArtworkUserIdsCommand.php
Normal file
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
|
||||
final class CheckArtworkUserIdsCommand extends Command
|
||||
{
|
||||
protected $signature = 'artworks:check-user-ids
|
||||
{--chunk=1000 : Number of artworks to process per chunk}
|
||||
{--show-missing=25 : Maximum number of missing references to print}
|
||||
{--artwork-id= : Only check this specific artwork ID}
|
||||
{--json : Output the summary as JSON}';
|
||||
|
||||
protected $description = 'Check whether every artworks.user_id exists in the users table.';
|
||||
|
||||
public function handle(): int
|
||||
{
|
||||
$options = [
|
||||
'--chunk' => (string) max(1, (int) $this->option('chunk')),
|
||||
'--show-missing' => (string) max(0, (int) $this->option('show-missing')),
|
||||
];
|
||||
|
||||
if ($this->option('artwork-id') !== null) {
|
||||
$options['--artwork-id'] = (string) (int) $this->option('artwork-id');
|
||||
}
|
||||
|
||||
if ((bool) $this->option('json')) {
|
||||
$options['--json'] = true;
|
||||
}
|
||||
|
||||
return $this->call('artworks:check-user-refs', $options);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user