getDataFromBlocks($block);
}
// Удаляем лишние пробелы и переносы строк
$result = preg_replace('/\s+/', ' ', $result);
$result = trim($result);
// Приводим текст к нижнему регистру
$data['search_data'] = strtolower($result);
return $data;
}
protected function afterCreate(): void
{
$recipient = auth()->user();
Notification::make()
->title('Новость на проверку')
->body('Новая запись была создана!')
->actions([
Action::make('view')
->label('Проверить')
->button()
->markAsRead()
->url(PostResource::getUrl('edit', ['record' => $this->record])),
])
->sendToDatabase($recipient);
}
private function calculateReadingTime(string $text): int
{
// Calculate the number of words in the text
$wordCount = str_word_count($text,0,"АаБбВвГгДдЕеЁёЖжЗзИиЙйКкЛлМмНнОоПпРрСсТтУуФфХхЦцЧчШшЩщЪъЫыЬьЭэЮюЯя");
// Calculate the average reading speed in words per minute
$wordsPerMinute = 120; // You can adjust this value based on your desired reading speed
// Calculate the reading time in minutes
$readingTime = $wordCount / $wordsPerMinute;
// Round the reading time to the nearest integer
$readingTime = round($readingTime);
return $readingTime;
}
protected function convertDataToHtml($blocks) {
$convertedHtml = "";
foreach ($blocks as $block) {
switch ($block['type']) {
case "header":
$convertedHtml .= "
" . $block['data']['text'] . "
"; break; case "delimiter": $convertedHtml .= "| " . $th . " | "; } $convertedHtml .= "
|---|
| " . $td . " | "; } $convertedHtml .= "