tissue/app/Console/Commands/NormalizeTags.php

51 lines
1020 B
PHP

<?php
namespace App\Console\Commands;
use App\Tag;
use App\Utilities\Formatter;
use Illuminate\Console\Command;
class NormalizeTags extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'tissue:tag:normalize';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Normalize tags';
private $formatter;
/**
* Create a new command instance.
*
* @return void
*/
public function __construct(Formatter $formatter)
{
parent::__construct();
$this->formatter = $formatter;
}
/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
foreach (Tag::query()->orderBy('name')->cursor() as $tag) {
$normalizedName = $this->formatter->normalizeToSearchIndex($tag->name);
$this->line("{$tag->name} : {$normalizedName}");
}
}
}