diff --git a/app/Services/Registries/CleanerService.php b/app/Services/Registries/CleanerService.php new file mode 100644 index 0000000..e08a2d9 --- /dev/null +++ b/app/Services/Registries/CleanerService.php @@ -0,0 +1,40 @@ +cleanPublications(); + $this->cleanRegistryEntries(); + } + + public function cleanPublications() { + $items = Publication::all(); + foreach ($items as $item) { + $item->update(['name' => $this->cleanString($item->name), 'excerpt' => $this->cleanString($item->excerpt)]); + } + } + + public function cleanRegistryEntries() { + $items = Entry::all(); + foreach ($items as $item) { + $item->update(['name' => $this->cleanString($item->name)]); + } + } + + + public function cleanString(string $string): string { + $string = Str::replace('"', '"', $string); + $string = Str::replace('(', '«', $string); + $string = Str::replace(')', '»', $string); + return trim(Str::replace('(***)', '', $string)); + } + +} \ No newline at end of file diff --git a/routes/console.php b/routes/console.php index b78034c..50ee834 100644 --- a/routes/console.php +++ b/routes/console.php @@ -28,6 +28,11 @@ Artisan::command('dev:generate-personal-token {userId}', function ($userId) { })->describe('Generates a personal access token for a user'); +Artisan::command('cleaner:clean', function() { + +}); + + Artisan::command('htmlparser:import-rulesets', function() { $registry = Registry::query()->where(['type' => RegistryType::RULESET])->first();