ldc-legaulois/app/Console/Commands/MigrateOldMessage.php
Vincent BRIDIER fda27cfe33
Mig
2024-09-23 19:19:50 +02:00

39 lines
861 B
PHP

<?php
namespace App\Console\Commands;
use App\Models\Message;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\Crypt;
class MigrateOldMessage extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'app:migrate-old-message';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Command description';
/**
* Execute the console command.
*
* @return void
*/
public function handle()
{
// Comment casting before run this command.
$messages = Message::all();
foreach ($messages as $message) {
$message->setAttribute('message', Crypt::encryptString($message->getRawOriginal('message')));
$message->save();
}
}
}