UnknownSec Bypass
403
:
/
var
/
www
/
html
/
lms_9d655b94864d
/
app
/
Repositories
/
Environment
/ [
drwxr-xr-x
]
Menu
Upload
Mass depes
Mass delete
Terminal
Info server
About
name :
HiredCourseRepositoryEloquent.php
<?php namespace EstudioLMS\Repositories\Environment; use Carbon\Carbon; use EstudioLMS\Models\Environment\HiredCourse; use Prettus\Repository\Eloquent\BaseRepository; /** * Class HireRepositoryEloquent * @package EstudioLMS\Repositories\Environment */ class HiredCourseRepositoryEloquent extends BaseRepository implements HiredCourseRepository { /** * Specify Model class name * * @return string */ public function model() { return HiredCourse::class; } /** * @param $userId * @param $courseSlug * @return mixed */ public function getCourseDetails($userId, $courseSlug) { return $this->model ->with([ 'course', 'course.category', 'course.user', 'course.level', 'course.modules_available.resources_available' ]) ->where('user_id', '=', $userId) ->whereIn('status', [3, 4]) ->CourseSlug($courseSlug) ->first(); } /** * @param array $attributes * @param $header_id * @return mixed */ public function updateStatusCallback(array $attributes, $header_id) { return $this->model->where('hirings_id', '=', $header_id) ->update($attributes); } /** * @param $id * @param $status * @return mixed */ public function massStatusUpdate($id, $status) { return $this->model ->where('hirings_id', '=', $id) ->update(['status' => $status]); } /** * @param $userId * @param $courseId * @return mixed */ public function getCourseDetailsById($userId, $courseId) { return $this->model ->with([ 'course', 'course.category', 'course.user', 'course.level', 'course.modules' => function($query) { $query->whereRaw('((modules.published_at <= now() OR modules.published_at is null) and ((modules.unpublished_at >= now() OR modules.unpublished_at is null)))') ->where('modules.published', '=', 1); }, 'course.modules.lessons' ]) ->where('user_id', '=', $userId) ->CourseId($courseId) ->first(); } /** * @param $studentId * @return mixed */ public function getStudentValidCourses($studentId) { return $this->model ->with('course') ->where('user_id', '=', $studentId) ->where(function ($query) { $query->where('status', '=', 2); $query->orWhere('status', '=', 3); $query->orWhere('status', '=', 4); })->get(); } /** * @param $id * @param $status * @return mixed */ public function updateStatusById($id, $status) { return $this->model ->where('id', '=', $id) ->update(['status' => $status]); } /** * @param $headerId * @param $courseId * @param $status * @return mixed */ public function updateStatusByHeaderId($headerId, $courseId, $status) { return $this->model ->where('hirings_id', '=', $headerId) ->where('course_id', '=', $courseId) ->update(['status' => $status]); } /** * @param $courseId * @param null $userId * @return mixed */ public function getHiredCoursesWithStudentData($courseId, $userId = null) { $result = $this->model ->join('users', 'hired_courses.user_id', '=', 'users.id') ->join('courses', 'hired_courses.course_id', '=', 'courses.id') ->where('hired_courses.course_id', '=', $courseId) ->select( [ 'users.id', 'users.name', 'users.email', 'courses.id AS course_id', 'courses.name as course_name' ] ); if(!is_null($userId)) { $result->where('hired_courses.user_id', $userId); } return $result; } /** * @param bool $countFreeCourses Conta também os usuários com curso gratuíto. * @return int */ public function activeUsers($countFreeCourses = true) { $result = $this->model ->selectRaw('COUNT(*) AS actives, hired_courses.user_id') ->join('hirings', 'hirings_id', '=','hirings.id') ->whereIn('hired_courses.status', [3, 4]) ->whereRaw('hirings.gateway_id <> "PagarMe"') ->groupBy('hired_courses.user_id') ->orderBy('hired_courses.user_id'); if (!$countFreeCourses) { $result = $result->where('is_free', '=', false); } $result = $result->get(); $activies = count($result); return $activies; } /** * @param $userId * @param bool $forDelete * @return array|\Illuminate\Database\Eloquent\Builder[]|\Illuminate\Database\Eloquent\Collection|\Illuminate\Database\Eloquent\Model[] */ public function hiredCourses($userId, $forDelete = false) { $status = [1, 2, 3, 4, 10]; if ($forDelete) { $status = [1, 2, 3, 4]; } return $this->model ->with(['course']) ->where('user_id', '=', $userId) ->whereIn('status', [1, 2, 3, 4, 10]) ->get(); } /** * @return $this|mixed */ public function withTrashed() { $this->model = $this->model->withTrashed(); return $this; } /** * @inheritDoc */ public function setCompleted($userId, $courseId) { return $this->model ->whereHas('course', function($query) { $query->where('course_status_id', '<>', 2); }) ->where('user_id', '=', $userId) ->where('course_id', '=', $courseId) ->where('completed', '=', false) ->update([ 'completed' => true, 'completed_at' => Carbon::now() ]); } /** * @param $studentId * @return mixed */ public function getStudentActiveEnrolls($studentId) { return $this->model ->where('user_id', '=', $studentId) ->whereIn('status', [2, 3, 4]) ->get(); } }
Copyright © 2026 - UnknownSec