Skip to content

Commit

Permalink
Merge pull request #22 from Moros1138/play-around-with-artisan-commands
Browse files Browse the repository at this point in the history
add custom artisan command to recompute code hashes
  • Loading branch information
Moros1138 authored Apr 25, 2024
2 parents f0ec0a9 + 157c27a commit ec19c9f
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 ec19c9f

Please sign in to comment.