Skip to content

Commit

Permalink
add custom artisan command to recompute code hashes
Browse files Browse the repository at this point in the history
  • Loading branch information
Moros1138 committed Apr 25, 2024
1 parent f0ec0a9 commit 157c27a
Showing 1 changed file with 42 additions and 0 deletions.
42 changes: 42 additions & 0 deletions app/Console/Commands/ComputeCodeHashes.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<?php

namespace App\Console\Commands;

use App\Http\Controllers\CodeController;
use App\Models\Code;
use Illuminate\Console\Command;

class ComputeCodeHashes extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'app:compute-code-hashes';

/**
* The console command description.
*
* @var string
*/
protected $description = 'Computes the hashes of all codes.';


/**
* Execute the console command.
*/
public function handle()
{
$controller = new CodeController();

$codes = Code::all();

foreach($codes as $code)
{
$code->hash = $controller->hashCode($code->code);
$code->save();
}

}
}

0 comments on commit 157c27a

Please sign in to comment.