⚝
One Hat Cyber Team
⚝
Your IP:
216.73.216.177
Server IP:
50.6.168.112
Server:
Linux server-617809.webnetzimbabwe.com 5.14.0-570.25.1.el9_6.x86_64 #1 SMP PREEMPT_DYNAMIC Wed Jul 9 04:57:09 EDT 2025 x86_64
Server Software:
Apache
PHP Version:
8.4.10
Buat File
|
Buat Folder
Eksekusi
Dir :
~
/
home
/
ctaacademy
/
www
/
app
/
Http
/
Resources
/
API
/
View File Name :
CourseDetailsCollection.php
*/ public function toArray(Request $request): array { if ($request->routeIs('api.learning')) { $user_id = auth()->id(); $currentProgress = CourseProgress::where('user_id', $user_id) ->where('course_id', $this->id) ->where('current', 1) ->orderBy('id', 'desc') ->first(); if (!$currentProgress) { $lessonId = @$this->chapters?->first()?->chapterItems()?->first()?->lesson->id; if ($lessonId) { $currentProgress = CourseProgress::create([ 'user_id' => $user_id, 'course_id' => $this->id, 'chapter_id' => $this->chapters->first()->id, 'lesson_id' => $lessonId, 'current' => 1, ]); } } $alreadyWatchedLectures = CourseProgress::where('user_id', $user_id) ->where('course_id', $this->id) ->where('type', 'lesson') ->where('watched', 1) ->pluck('lesson_id') ->toArray(); $alreadyCompletedQuiz = CourseProgress::where('user_id', $user_id) ->where('course_id', $this->id) ->where('type', 'quiz') ->where('watched', 1) ->pluck('lesson_id') ->toArray(); return [ 'thumbnail' => (string) $this->thumbnail, 'title' => (string) $this->title, 'instructor' => new InstructorResource($this->instructor), 'curriculums' => ChapterResource::collection($this->chapters), 'current_progress' => new CurrentProgressResource($currentProgress), 'already_watched_lectures' => (array) $alreadyWatchedLectures, 'already_completed_quiz' => (array) $alreadyCompletedQuiz, ]; } $currency = strtoupper($request->query('currency')); return [ 'demo_video' => (string) generateVideoEmbedUrl($this->demo_video_source, $this->demo_video_storage), 'thumbnail' => (string) $this->thumbnail, 'is_wishlist' => (bool) $this->is_wishlist, 'title' => (string) $this->title, 'slug' => (string) $this->slug, 'instructor' => new InstructorResource($this->instructor), 'average_rating' => (float) $this->average_rating ?? 0, 'reviews_count' => (int) $this->reviews_count ?? 0, 'students' => (int) $this->enrollments_count ?? 0, 'last_updated' => (string) formatDate($this->updated_at), 'duration' => (string) convertMinutesToHoursAndMinutes($this->duration), 'certificate' => (bool) $this->certificate, 'lessons_count' => (int) $this->lessons_count ?? 0, 'quizzes_count' => (int) $this->quizzes_count ?? 0, 'languages' => (string) $this->languages->pluck('language.name')->implode(', '), 'price' => (string) apiCurrency($this->price, $currency), 'discount' => (string) apiCurrency($this->discount, $currency), 'description' => (string) $this->description, 'curriculums' => ChapterResource::collection($this->chapters), ]; } }