示例#1
0
 /**
  * @param $token_id
  *
  * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
  */
 public function showLogs($token_id)
 {
     $logs = ApiTokenLog::with(['token' => function ($query) use($token_id) {
         $query->where('id', $token_id);
     }])->orderBy('created_at', 'desc')->paginate(50);
     return view('api::logs', compact('logs'));
 }
示例#2
0
文件: ApiToken.php 项目: eveseat/api
 /**
  * Log an API request based on the config setting
  *
  * @param \Illuminate\Http\Request $request
  * @param                          $action
  */
 public function log_activity(Request $request, $action)
 {
     if (config('api.config.log_requests')) {
         $token_id = ApiTokenModel::where('token', $request->header('X-Token'))->value('id');
         ApiTokenLog::create(['api_token_id' => $token_id, 'action' => $action, 'request_path' => $request->path(), 'src_ip' => $request->getClientIp()]);
     }
 }