Пример #1
0
 public function getTweets(&$contents, $tid)
 {
     $images = Tweet::getRelated();
     foreach ($images as $image) {
         $data = $image->toArray();
         $user = $data['user'];
         if (!isset($tid)) {
             $tid = 0;
         }
         $contents[$data['tid'] != $tid ? (string) $data['tid'] : 0] = array('tid' => $data['tid'], 'content' => $data['content'], 'name' => $user['name'], 'user' => $user['user'], 'url' => $user['url']);
     }
     ksort($contents);
     $contents = array_reverse($contents);
 }
Пример #2
0
 public function delete(Request $request)
 {
     $list = json_decode($request->input('list'));
     foreach ($list as $item) {
         $remove[$item->type][] = $item->tid;
     }
     if (array_key_exists('tweets', $remove)) {
         Tweet::markAsInactive($remove['tweets']);
     }
     if (array_key_exists('twitpics', $remove)) {
         Image::markAsInactive($remove['twitpics']);
     }
     if (array_key_exists('instagram', $remove)) {
         Image::markAsInactive($remove['instagram']);
     }
     if (array_key_exists('dropbox', $remove)) {
         Dbox::markAsInactive($remove['dropbox']);
     }
     // return?
 }
Пример #3
0
 public function addToDB($users, $tweets, $images, $streams, $debug)
 {
     // Users
     $collection = collect($users);
     $usernames = array_map('strtolower', $this->formatCollection(User::all(['user']), true));
     $filtered = $collection->filter(function ($item) use($usernames) {
         return !in_array(strtolower($item['user']), $usernames);
     });
     User::insert($filtered->toArray());
     // Tweets
     $collection = collect($tweets);
     $tids = $this->formatCollection(Tweet::all(['tid']));
     $filtered = $collection->filter(function ($item) use($tids) {
         return !in_array($item['tid'], $tids);
     });
     Tweet::insert($filtered->toArray());
     // Images
     $collection = collect($images);
     $tids = $this->formatCollection(Image::all(['tid']));
     $filtered = $collection->filter(function ($item) use($tids) {
         return !in_array($item['tid'], $tids);
     });
     Image::insert($filtered->toArray());
 }