| xqd
@@ -54,6 +54,47 @@ class Student extends Model
|
|
|
return StudentCourse::where('student_id', $this['id'])->first();
|
|
|
}
|
|
|
|
|
|
+ public function getCourseInfo()
|
|
|
+ {
|
|
|
+ $student_course = StudentCourse::where('student_id', $this['id'])->first();
|
|
|
+ if(empty($student_course)) {
|
|
|
+ return [
|
|
|
+ 'course_name' => '',
|
|
|
+ 'apply_date' => '',
|
|
|
+ 'end_date' => '',
|
|
|
+ 'teacher_names' => ''
|
|
|
+ ];
|
|
|
+ }
|
|
|
+ $course = Course::find($student_course->course_id);
|
|
|
+ if(empty($course)) {
|
|
|
+ $course_name = '';
|
|
|
+ } else {
|
|
|
+ $course_name = $course->name;
|
|
|
+ }
|
|
|
+
|
|
|
+ $apply_date = $student_course->apply_date;
|
|
|
+ if(empty($apply_date) || empty($student_course->duration)) {
|
|
|
+ $end_date = '';
|
|
|
+ } else {
|
|
|
+ $end_date = Carbon::createFromTimestamp(strtotime($apply_date))->addDays($student_course->duration)->toDateString();
|
|
|
+ }
|
|
|
+ $teacher_names = $student_course->getTeacherFullNames();
|
|
|
+ return [
|
|
|
+ 'course_name' => $course_name,
|
|
|
+ 'apply_date' => $apply_date,
|
|
|
+ 'end_date' => $end_date,
|
|
|
+ 'teacher_names' => $teacher_names
|
|
|
+ ];
|
|
|
+ }
|
|
|
+
|
|
|
+ public function getCourseName()
|
|
|
+ {
|
|
|
+ $student_course = StudentCourse::where('student_id', $this['id'])->first();
|
|
|
+ if(empty($student_course)) return '';
|
|
|
+ $course = Course::find($student_course->course_id);
|
|
|
+ return empty($course) ? '' : $course->name;
|
|
|
+ }
|
|
|
+
|
|
|
public function getIsNew()
|
|
|
{
|
|
|
$today = Carbon::today();
|