app/Http/Controllers/IndexController.php
/**
   * This is ugly but i don`t know any better way for now
   */
This is ugly but i don`t know any better way for now
This is ugly but i don ` t know any better way for now
private function buildMoreHtml($request, $relatedNews){
    $totalRelated = count($relatedNews); 
    $startPoint = $totalRelated - $request->relatedLeft;  - 4 = 2
    $relatedNews = array_slice($relatedNews, $startPoint, 2);
    $sinlge_link = $request->relatedSingleLink;
    $folder = $request->relatedFolder;
    $image_prefix = $request->relatedImagePrefix;
    $html = [];
    foreach ($relatedNews as $related){
      $published = $related->created_at->format('H:i m.d.Y');
      $body = str_limit(strip_tags($related->body, '<p><b><em><ol><ul><li>'), $limit = 550, $end = '...');
      $tagg = '';
      if(method_exists($related,'tag')) {
        if (count($related->tag())) {
          $tagg = '<span>Теги: </span>';
          foreach ($related->tag as $k => $tag) {
            if ($k != 0) {
              $tagg .= '<span class="coma">,</span>';
            }
            $tagg .= "<span><a href='/tag/$tag->slug'>$tag->title</a></span>";
          }
        }
      }
      $html[] = "<div class='news-wrapper clearfix'>
                <div class='n-image col-md-3'>
                    <a href='/$sinlge_link/$related->slug'>
                        <img src='/images/$folder/$related->id/$image_prefix" . '_' . "$related->cover_image'
                             alt='$related->cover_alt'
                             title='$related->cover_title'
                             width='250px' height='180px'
                        />
                    </a>
                </div>
                <div class='n-text col-md-9'>
                    <h4>
                        <a href='/$sinlge_link/$related->slug'>
                            $related->title
                        </a>
                    </h4>
                    <div class='n-tags'>
                    $tagg
                    </div>
                    <div class='n-published'>
                        <span>Опубліковано:</span>
                        <span class='n-time'>$published</span>
                    </div>
                    <div class='nbody'>
                        $body
                        <span class='read-more'><a href='/$sinlge_link/$related->slug'>читати далі</a></span>
                    </div>
                    <div class='n-author'>$related->author_name</div>
                </div>
            </div>
        <hr class='divider'>";
    }
    return $html;
  }
private function buildMoreHtml ( $ request , $ relatedNews ) { $ totalRelated = count ( $ relatedNews ) ; $ startPoint = $ totalRelated - $ request -> relatedLeft ; $ relatedNews = array_slice ( $ relatedNews , $ startPoint , 2 ) ; $ sinlge_link = $ request -> relatedSingleLink ; $ folder = $ request -> relatedFolder ; $ image_prefix = $ request -> relatedImagePrefix ; $ html = [ ] ; foreach ( $ relatedNews as $ related ) { $ published = $ related -> created_at -> format ( 'H:i m.d.Y' ) ; $ body = str_limit ( strip_tags ( $ related -> body , '<p><b><em><ol><ul><li>' ) , $ limit = 550 , $ end = '...' ) ; $ tagg = '' ; if ( method_exists ( $ related , 'tag' ) ) { if ( count ( $ related -> tag ( ) ) ) { $ tagg = '<span>Теги: </span>'; foreach ( $ related -> tag as $ k => $ tag ) { if ( $ k != 0 ) { $ tagg .= '<span class="coma">,</span>' ; } $ tagg .= " <span><a href='/tag/ $ tag -> slug '> $ tag -> title </a></span> " ; } } } $ html [ ] = " <div class='news-wrapper clearfix'>
                <div class='n-image col-md-3'>
                    <a href='/ $ sinlge_link / $ related -> slug '>
                        <img src='/images/ $ folder / $ related -> id / $ image_prefix " . '_' . " $ related -> cover_image '
                             alt=' $ related -> cover_alt '
                             title=' $ related -> cover_title '
                             width='250px' height='180px'
                        />
                    </a>
                </div>
                <div class='n-text col-md-9'>
                    <h4>
                        <a href='/ $ sinlge_link / $ related -> slug '>
                             $ related -> title 
                        </a>
                    </h4>
                    <div class='n-tags'>
                     $ tagg 
                    </div>
                    <div class='n-published'>
                        <span>Опубліковано:</span>
                        <span class='n-time'> $ published </span>
                    </div>
                    <div class='nbody'>
                         $ body 
                        <span class='read-more'><a href='/ $ sinlge_link / $ related -> slug '>читати далі</a></span>
                    </div>
                    <div class='n-author'> $ related -> author_name </div>
                </div>
            </div>
        <hr class='divider'> " ; } return $ html ; }
This is ugly but i don`t know any better way for now
This is ugly but i don ` t know any better way for now
//6 //6 - 4 = 2