Skip to content

Commit

Permalink
Access the ApiLog instance from the controller
Browse files Browse the repository at this point in the history
Useful if we want to reference an API call to a transaction.
  • Loading branch information
awkwardusername committed Apr 23, 2015
1 parent dd5f3b3 commit 529424e
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions src/Http/Controllers/ApiGuardController.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use App;
use Chrisbjr\ApiGuard\Repositories\ApiKeyRepository;
use Chrisbjr\ApiGuard\Repositories\ApiLogRepository;
use Config;
use EllipseSynergie\ApiResponse\Laravel\Response;
use Exception;
Expand All @@ -27,6 +28,12 @@ class ApiGuardController extends Controller
*/
public $apiKey = null;


/**
* @var ApiLogRepository
*/
public $apiLog = null;

/**
* @var Response
*/
Expand Down Expand Up @@ -198,17 +205,17 @@ public function __construct()

if ($logged) {
// Log this API request
$apiLog = App::make(Config::get('api-guard::apiLogModel', 'Chrisbjr\ApiGuard\Models\ApiLog'));
$this->apiLog = App::make(Config::get('api-guard::apiLogModel', 'Chrisbjr\ApiGuard\Models\ApiLog'));

if (isset($this->apiKey)) {
$apiLog->api_key_id = $this->apiKey->id;
$this->apiLog->api_key_id = $this->apiKey->id;

This comment has been minimized.

Copy link
@awkwardusername

awkwardusername May 3, 2015

Author Collaborator

Can be a bug: For ref #48

}

$apiLog->route = Route::currentRouteAction();
$apiLog->method = $request->getMethod();
$apiLog->params = http_build_query(Input::all());
$apiLog->ip_address = $request->getClientIp();
$apiLog->save();
$this->apiLog->route = Route::currentRouteAction();
$this->apiLog->method = $request->getMethod();
$this->apiLog->params = http_build_query(Input::all());
$this->apiLog->ip_address = $request->getClientIp();
$this->apiLog->save();

}
}
Expand Down

0 comments on commit 529424e

Please sign in to comment.