list.blade.php

v.1
@php
$maxLength = 350;
if(mb_strlen(strip_tags($document->getContent(false))) > $maxLength){
// $content = preg_replace('/<img[^>]*>/', '', $document->variables['content']);
// $shortContent = mb_substr($content, 0, $maxLength) . '...';
$fullUrl = getUrl('document_srl'$document->document_srl); // 문서의 URL 생성
$content $document->getSummary($maxLength);
$content .= " <a href='" $fullUrl "' class='read-more'>더보기</a>";
echo $content;
}else{
// echo '이하';
$content = preg_replace('/<img[^>]*>/'''$document->variables['content']);
//  echo $document->getContent(false);
echo $content;
}
@endphp


v.2 : 공백 제거하는 부분 추가함

@php
                         $maxLength = 350;
                         if(mb_strlen(strip_tags($document->getContent(false))) > $maxLength){
                            // $content = preg_replace('/<img[^>]*>/', '', $document->variables['content']);
                            // $shortContent = mb_substr($content, 0, $maxLength) . '...';
                            $fullUrl = getUrl('document_srl', $document->document_srl); // 문서의 URL 생성
                            $content = $document->getSummary($maxLength);
                            $content .= " <a href='" . $fullUrl . "' class='read-more'>더보기</a>";
                            echo $content;
                         }else{
//                          echo '이하';
//                          $content = preg_replace('/<p><br><\/p>/', '', $document->variables['content']);
                            $content = preg_replace('/<img[^>]*>/', '', $document->variables['content']);
                            $content = preg_replace('/<br\s*\/?>/i', '', $content);
//                           echo $document->getContent(false);
                            echo $content;
                         }
                      @endphp