Przeglądaj źródła

[STAG-25] Patients list - hide past appointments

Vijayakrishnan Krishnan 4 lat temu
rodzic
commit
b725c1b08e
2 zmienionych plików z 8 dodań i 2 usunięć
  1. 6 0
      app/Models/Client.php
  2. 2 2
      resources/views/app/patients.blade.php

+ 6 - 0
app/Models/Client.php

@@ -87,6 +87,12 @@ class Client extends Model
             ->orderBy('start_time', 'desc');
     }
 
+    public function upcomingAppointments() {
+        return $this->hasMany(Appointment::class, 'client_id', 'id')
+            ->where('start_time', '>=', date('Y-m-d'))
+            ->orderBy('start_time', 'desc');
+    }
+
     public function memos() {
         return $this->hasMany(ClientMemo::class, 'client_id', 'id')
             ->where('is_cancelled', false)

+ 2 - 2
resources/views/app/patients.blade.php

@@ -71,7 +71,7 @@
                         <td>
                             <table class="table table-sm border-0 my-0">
                                 <tbody>
-                                @foreach($patient->appointments as $appointment)
+                                @foreach($patient->upcomingAppointments as $appointment)
                                     <tr>
                                         <td class="text-black p-0 border-0">
                                             <div class="pb-0">
@@ -85,7 +85,7 @@
                                         </td>
                                     </tr>
                                 @endforeach
-                                @if(!$patient->appointments || count($patient->appointments) === 0)
+                                @if(!$patient->upcomingAppointments || count($patient->upcomingAppointments) === 0)
                                     <tr>
                                         <td class="text-secondary p-0 border-0">
                                             No appointments