Example #1
0
 /**
  * Return User associated with APIKey.
  *
  * @param string $key
  *
  * @return Screeenly\User
  */
 public static function getUserByKey($key)
 {
     // Search for key in ApiKey Model
     $apiKey = ApiKey::whereKey($key)->first();
     if ($apiKey) {
         return $apiKey->user;
     }
 }
 /**
  * Set Api Key
  * @param mixed (string|null) $key
  */
 public function setKey($key)
 {
     if (!is_null($key)) {
         $key = $this->apiKey->whereKey($key)->first();
         if (!$key) {
             throw new InvalidApiKeyException("The API Key {$key} is invalid.", 401);
         }
     }
     return $this->key = $key;
 }
Example #3
0
 public static function store(Screenshot $screenshot, User $user)
 {
     $key = \Input::get('key', null);
     $apiKey = ApiKey::whereKey($key)->first();
     $log = new self();
     $log->images = $screenshot->storagePath;
     $log->user()->associate($user);
     if (!is_null($apiKey)) {
         $log->apiKey()->associate($apiKey);
     }
     $log->save();
     return $log;
 }