Explorar o código

[STAG-25] Patients list - hide past appointments

Vijayakrishnan Krishnan %!s(int64=4) %!d(string=hai) anos
pai
achega
b725c1b08e
Modificáronse 2 ficheiros con 8 adicións e 2 borrados
  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