public function __construct() { if (Sentry::check()) { $this->user = Sentry::getUser(); } else { $inputKey = Input::get('apikey'); if (empty($inputKey)) { return Response::api('Invalid authorization token.', 401); } $key = APIKey::where('key', $inputKey); $this->user = $key->user()->get(); } }