Example #1
0
 /**
  * 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()]);
     }
 }
Example #2
0
 /**
  * @param $token_id
  *
  * @return \Illuminate\Http\RedirectResponse
  */
 public function deleteToken($token_id)
 {
     ApiToken::findOrFail($token_id)->delete();
     return redirect()->back()->with('success', 'Token deleted');
 }