Replace Slot ID column in lessons list with the lesson's date/time
CI / Tests (PHP 8.2) (pull_request) Successful in 1m20s
CI / Tests (PHP 8.1) (pull_request) Successful in 1m21s
CI / Coding Standards (pull_request) Successful in 1m45s
CI / PHPStan (pull_request) Successful in 3m22s
CI / No Debug Code (pull_request) Successful in 3s
CI / Tests (PHP 8.3) (pull_request) Successful in 2m36s
CI / Build Plugin Zip (pull_request) Has been skipped
CI / Tests (PHP 8.2) (pull_request) Successful in 1m20s
CI / Tests (PHP 8.1) (pull_request) Successful in 1m21s
CI / Coding Standards (pull_request) Successful in 1m45s
CI / PHPStan (pull_request) Successful in 3m22s
CI / No Debug Code (pull_request) Successful in 3s
CI / Tests (PHP 8.3) (pull_request) Successful in 2m36s
CI / Build Plugin Zip (pull_request) Has been skipped
The admin dashboard and instructor My Lessons pages showed the raw availability-slot database ID, which is meaningless to admins and instructors. LessonController now takes AvailabilityRepository, looks up each lesson's slot, and renders its window as e.g. "Jul 6, 2026 9:00 AM-10:00 AM" via mysql2date. The date is repeated on the end time only when a slot crosses midnight, and lessons whose slot row no longer exists show an em dash. Closes #47 Co-Authored-By: Claude Fable 5 <[email protected]>
This commit is contained in:
@@ -4,6 +4,8 @@ declare(strict_types=1);
|
||||
namespace Unsupervised\Schedular\Booking;
|
||||
|
||||
use Unsupervised\Schedular\Auth\RoleManager;
|
||||
use Unsupervised\Schedular\Availability\AvailabilityRepository;
|
||||
use Unsupervised\Schedular\Availability\AvailabilitySlot;
|
||||
use Unsupervised\Schedular\Payment\Payment;
|
||||
use Unsupervised\Schedular\Payment\PaymentRepository;
|
||||
use Unsupervised\Schedular\Val;
|
||||
@@ -13,6 +15,7 @@ class LessonController {
|
||||
public function __construct(
|
||||
private BookingRepository $repository,
|
||||
private PaymentRepository $payments,
|
||||
private AvailabilityRepository $availability,
|
||||
) {}
|
||||
|
||||
public function renderAdminDashboard(): void {
|
||||
@@ -83,11 +86,12 @@ class LessonController {
|
||||
$student = get_userdata( $lesson->studentId );
|
||||
$instructor = get_userdata( $lesson->instructorId );
|
||||
$payment = null !== $lesson->paymentId ? $this->payments->findById( $lesson->paymentId ) : null;
|
||||
$slot = $this->availability->findById( $lesson->slotId );
|
||||
|
||||
return [
|
||||
'student' => $student ? $student->display_name : (string) $lesson->studentId,
|
||||
'instructor' => $instructor ? $instructor->display_name : (string) $lesson->instructorId,
|
||||
'slot_id' => (int) $lesson->slotId,
|
||||
'time' => $slot ? $this->formatSlotTime( $slot ) : '—',
|
||||
'status' => $lesson->status,
|
||||
'notes' => $lesson->notes ?? '',
|
||||
'payment_id' => $payment ? (int) $payment->id : 0,
|
||||
@@ -101,4 +105,16 @@ class LessonController {
|
||||
'tax_editable' => null !== $payment && ! $payment->isPaid(),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Format a slot's window as e.g. "Jul 6, 2026 9:00 AM–10:00 AM", repeating the
|
||||
* date on the end time only when the slot crosses midnight.
|
||||
*/
|
||||
private function formatSlotTime( AvailabilitySlot $slot ): string {
|
||||
$sameDay = substr( $slot->startDt, 0, 10 ) === substr( $slot->endDt, 0, 10 );
|
||||
|
||||
return Val::string( mysql2date( 'M j, Y g:i A', $slot->startDt ) )
|
||||
. '–'
|
||||
. Val::string( mysql2date( $sameDay ? 'g:i A' : 'M j, Y g:i A', $slot->endDt ) );
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user