Jelajahi Sumber

Admin dashboard - show appt creator and when

Vijayakrishnan 3 tahun lalu
induk
melakukan
56ec1e6f8b

+ 3 - 0
app/Http/Controllers/HomeController.php

@@ -1560,6 +1560,9 @@ WHERE measurement.label NOT IN ('SBP', 'DBP')
             $appointment->clientAge = $appointment->client->age_in_years;
             $appointment->clientSex = $appointment->client->sex;
 
+            $appointment->createdBy = $appointment->creator ? $appointment->creator->displayName() : '';
+            $appointment->createdAt = friendly_date($appointment->created_at);
+
             $appointment->started = false;
             $appointment->inHowManyHours = date_diff(date_create('now'), date_create($appointment->start_time), false)
                 ->format('%R%h h, %i m');

+ 4 - 0
app/Models/Appointment.php

@@ -18,6 +18,10 @@ class Appointment extends Model
         return $this->hasOne(Pro::class, 'id', 'pro_id');
     }
 
+    public function creator() {
+        return $this->hasOne(Pro::class, 'id', 'created_by_pro_id');
+    }
+
     public function confirmationRequests() {
         return $this->hasMany(AppointmentConfirmationRequest::class, 'appointment_id', 'id')
             ->orderBy('created_at', 'desc');

+ 8 - 0
resources/views/app/dashboard-admin.blade.php

@@ -535,6 +535,8 @@
                                         <th class="border-bottom-0">Status</th>
                                         <th class="border-bottom-0">Coverage</th>
                                         <th class="border-bottom-0"></th>
+                                        <th class="border-bottom-0">Created By</th>
+                                        <th class="border-bottom-0">Created At</th>
                                     </tr>
                                     </thead>
                                     <tbody>
@@ -576,6 +578,12 @@
                                                 Edit
                                             </a>
                                         </td>
+                                        <td class="align-middle">
+                                            @{{ event.createdBy }}
+                                        </td>
+                                        <td class="align-middle">
+                                            @{{ event.createdAt }}
+                                        </td>
                                     </tr>
                                     </tbody>
                                 </table>