belongsTo('App\Models\WebinarChapter', 'chapter_id', 'id'); } public function learningStatus() { return $this->hasOne('App\Models\CourseLearning', 'file_id', 'id'); } public function personalNote() { return $this->morphOne('App\Models\CoursePersonalNote', 'targetable'); } public function isVideo() { return (in_array($this->file_type, self::$videoTypes)); } public function getFileDuration() { $duration = 0; if ($this->storage == 'upload') { $file_path = public_path($this->file); $getID3 = new \getID3; $file = $getID3->analyze($file_path); if (!empty($file) and !empty($file['playtime_seconds'])) { $duration = $file['playtime_seconds']; } } return convertMinutesToHourAndMinute($duration); } public function getIconByType($type = null) { $icon = 'file'; if (empty($type)) { $type = $this->file_type; } if (!empty($type)) { if (in_array($type, ['pdf', 'powerpoint', 'document'])) { $icon = 'file-text'; } else if (in_array($type, ['sound'])) { $icon = 'volume-2'; } else if (in_array($type, ['video'])) { $icon = 'film'; } else if (in_array($type, ['image'])) { $icon = 'image'; } else if (in_array($type, ['archive'])) { $icon = 'archive'; } } return $icon; } public function getVolume() { return $this->volume . ' MB'; } public function checkPassedItem() { $result = false; if (auth()->check()) { $check = $this->learningStatus()->where('user_id', auth()->id())->count(); $result = ($check > 0); } return $result; } }