Example #1
0
 public static function store(Screenshot $screenshot, User $user)
 {
     $log = new self();
     $log->images = $screenshot->storagePath;
     $log->user()->associate($user);
     $log->save();
     return $log;
 }
Example #2
0
 public static function add($object, $action, $change = [], $level = self::LEVEL_INFO)
 {
     $clog = new self();
     $clog->action = $action;
     $clog->change = $change;
     $clog->time = \Carbon\Carbon::now();
     $clog->user()->associate(\Session::get('user'));
     $clog->object()->associate($object);
     $clog->level = $level;
     $clog->save();
 }
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;
 }
Example #4
0
 public static function parse($response)
 {
     if (Tag::setof($tag, $response, "error")) {
         throw new Exception($tag->value());
     }
     if (Tag::setof($tag, $response, "status")) {
         $hash = $tag->hash();
         $obj = new self();
         $obj->user(TwitterUser::parse($hash["user"]));
         unset($hash["user"]);
         return $obj->cp($hash);
     }
     throw new Exception("invalid data");
 }
Example #5
0
 public static function instantiate(User $user, Comment $comment, bool $up = true)
 {
     $instance = new self();
     $instance->user()->associate($user);
     $instance->comment()->associate($comment);
     $instance->post_id = $comment->post_id;
     $instance->up = $up;
     $instance->save();
     if ($up) {
         $comment->increment('ups');
     } else {
         $comment->decrement('ups');
     }
     return $instance;
 }
Example #6
0
 public static function parse_list($response)
 {
     $result = array();
     $res = Text::parse_json($response);
     if (!isset($res)) {
         throw new Exception($response);
     }
     foreach ($res as $re) {
         $obj = new self();
         $obj->user(WassrUser::parse($re["user"]));
         unset($re["user"]);
         $result[] = $obj->cp($re);
     }
     return $result;
 }
Example #7
0
 public static function parse_list($response)
 {
     $result = array();
     $res = Text::parse_json($response);
     if (!empty($res)) {
         foreach ($res as $re) {
             $obj = new self();
             $obj->user(WassrUser::parse($re["user"]));
             unset($re["user"]);
             $obj->channel(WassrChannel::parse($re["channel"]));
             unset($re["channel"]);
             $result[] = $obj->cp($re);
         }
     }
     return $result;
 }