rightJoin('point_logs', 'point_logs.user_id', 'users.id')->groupBy('point_logs.user_id')->orderBy('total_point', 'desc')->get(); if($query){ $result = $query; $res_status = true; $msg = 'Mendapatkan Data'; $status_msg = $msg; return $this->resSuccess(null, $res_status, $msg, $status_msg, $result); }else { $res_status = false; $msg = 'Data tidak ditemukan'; $status_msg = $msg; return $this->resSuccess(null, $res_status, $msg, $status_msg, null); } } public function getNonEvent() { $query = User::select('users.name', 'users.id as user_id', DB::raw('SUM(point_logs.point) as total_point'))->rightJoin('point_logs', 'point_logs.user_id', 'users.id')->where('event_id', '=', 0)->groupBy('point_logs.user_id')->orderBy('total_point', 'desc')->get(); if($query){ $result = $query; $res_status = true; $msg = 'Mendapatkan Data'; $status_msg = $msg; return $this->resSuccess(null, $res_status, $msg, $status_msg, $result); }else { $res_status = false; $msg = 'Data tidak ditemukan'; $status_msg = $msg; return $this->resSuccess(null, $res_status, $msg, $status_msg, null); } } public function getWithEvent() { $query = User::select('users.name', 'users.id as user_id', DB::raw('SUM(point_logs.point) as total_point'))->rightJoin('point_logs', 'point_logs.user_id', 'users.id')->where('event_id', '=', 1)->groupBy('point_logs.user_id')->orderBy('total_point', 'desc')->get(); if($query){ $result = $query; $res_status = true; $msg = 'Mendapatkan Data'; $status_msg = $msg; return $this->resSuccess(null, $res_status, $msg, $status_msg, $result); }else { $res_status = false; $msg = 'Data tidak ditemukan'; $status_msg = $msg; return $this->resSuccess(null, $res_status, $msg, $status_msg, null); } } public function resSuccess($param = null, $status = null, $msg = null, $status_msg = null, $result = null) { $response['response'] = array( 'status' => $status, 'message' => $msg, 'status_msg' => $status_msg, ); $response['param'] = !empty($param) ? $param : ''; $response['results'] = $result; return response()->json($response, 200); } }