From 140875e6813793119f387839c29fb7d8afdc177e Mon Sep 17 00:00:00 2001 From: Martin Renvoize Date: Thu, 23 Sep 2021 19:06:43 +0100 Subject: [PATCH] Bug 28762: Use Koha::Course in course-details controller This patch updates Koha::Course to include the 'instructors' relation accessor and then update the course-details controller to use the Koha::Course object and pass it to the template instead of building a hash using GetCourse. Signed-off-by: Martin Renvoize Signed-off-by: Nick Clemens Signed-off-by: Martin Renvoize (cherry picked from commit 7f38c77d091cd4192b039041bcc3a00a05e10583) Signed-off-by: Lucas Gass --- Koha/Course.pm | 22 ++++++++++++++++++++-- course_reserves/course-details.pl | 2 +- 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/Koha/Course.pm b/Koha/Course.pm index 9ede81bd3c..6b67a2b592 100644 --- a/Koha/Course.pm +++ b/Koha/Course.pm @@ -17,14 +17,32 @@ package Koha::Course; use Modern::Perl; - use base qw(Koha::Object); =head1 NAME Koha::Course - Koha Course Object class -=head1 API +=head2 Relations + +=head3 instructors + + my $instructors = $course->instructors(); + +Returns the related Koha::Patrons object containing the instructors for this course + +=cut + +sub instructors { + my ($self) = @_; + + my $instructors = Koha::Patrons->search( + { 'course_instructors.course_id' => $self->course_id }, + { join => 'course_instructors' } + ); + + return $instructors; +} =head2 Internal methods diff --git a/course_reserves/course-details.pl b/course_reserves/course-details.pl index b2ca9e8c87..e5c0c3c5b8 100755 --- a/course_reserves/course-details.pl +++ b/course_reserves/course-details.pl @@ -56,7 +56,7 @@ if ( $op eq 'cud-del_reserve' ) { } } -my $course = GetCourse($course_id); +my $course = Koha::Courses->find($course_id); my $course_reserves = GetCourseReserves( course_id => $course_id, include_items => 1, -- 2.39.5