40 lines
1.0 KiB
PHP
40 lines
1.0 KiB
PHP
<?php
|
|
|
|
namespace App\Services\Registries;
|
|
|
|
use App\Models\Publications\Publication;
|
|
use App\Models\Registries\Entry;
|
|
use Illuminate\Support\Str;
|
|
|
|
class CleanerService {
|
|
public function __construct() {
|
|
}
|
|
|
|
public function clean() {
|
|
$this->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));
|
|
}
|
|
|
|
} |