Explorar o código

Note->summary()

Vijayakrishnan %!s(int64=4) %!d(string=hai) anos
pai
achega
b4c18048e2
Modificáronse 2 ficheiros con 13 adicións e 14 borrados
  1. 12 0
      app/Models/Note.php
  2. 1 14
      resources/views/app/patient/notes.blade.php

+ 12 - 0
app/Models/Note.php

@@ -44,4 +44,16 @@ class Note extends Model
             ->where('is_active', true)
             ->orderBy('position_index', 'asc');
     }
+
+    public function summary()
+    {
+        $parts = [];
+        foreach ($this->sections as $section) {
+            $parts[] = $section->summary_html;
+        }
+        $parts = array_map(function($_part) {
+             return '<div class="note-section-summary">' . $_part . '</div>';
+        }, $parts);
+        return implode("", $parts);
+    }
 }

+ 1 - 14
resources/views/app/patient/notes.blade.php

@@ -81,20 +81,7 @@
                 </td>
                 <td class="px-2 note-summary">
                     <div class="note-section-content-html-outer">
-                        <?php
-                        $textContent = strip_tags($note->free_text_html);
-                        if(strlen($textContent) > 200) {
-                            $textContent = substr($textContent, 0, 200) . '…';
-                        }
-                        ?>
-                        {!! $textContent !!}
-                        @foreach($note->sections as $section)
-                            @if(!!$section->summary_html)
-                                <div p-2 class="note-section-content-html">
-                                    {!! $section->summary_html !!}
-                                </div>
-                            @endif
-                        @endforeach
+                        {!! $note->summary() !!}
                     </div>
                 </td>
                 <td class="px-2">