/** * Clear a log. * * @param string $log * * @throws \UnexpectedValueException */ public function clear($log) { if ($log === 'change') { $this->changeRepository->clearLog(); } elseif ($log === 'system') { $this->systemRepository->clearLog(); } else { throw new \UnexpectedValueException("Invalid log type requested: {$log}"); } $this->app['logger.system']->info(ucfirst($log) . ' log cleared.', ['event' => 'security']); }
/** * Get a specific activity log. * * @param string $log The log to query. Either 'change' or 'system' * @param integer $page * @param integer $amount Number of results to return * @param array $options * * @throws \UnexpectedValueException * * @return array */ public function getActivity($log, $page = 1, $amount = 10, $options = []) { if ($log == 'change') { $rows = $this->changeRepository->getActivity($page, $amount, $options); $rowcount = $this->changeRepository->getActivityCount($options); } elseif ($log == 'system') { $rows = $this->systemRepository->getActivity($page, $amount, $options); $rowcount = $this->systemRepository->getActivityCount($options); } else { throw new \UnexpectedValueException("Invalid log type requested: {$log}"); } // Set up the pager $pager = ['for' => 'activity', 'count' => $rowcount, 'totalpages' => ceil($rowcount / $amount), 'current' => $page, 'showing_from' => ($page - 1) * $amount + 1, 'showing_to' => ($page - 1) * $amount + count($rows)]; $this->app['storage']->setPager('activity', $pager); return $rows; }