40 lines
861 B
PHP
40 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();
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|