Esempio n. 1
0
 private function getViewIndexDatas()
 {
     $current_user_id = Session::get('user')['id'];
     $owners_id = Follow::where('follower_id', $current_user_id)->where('is_deleted', 0)->get(['followed_id'])->toArray();
     array_walk($owners_id, function (&$value, $key) {
         $value = $value['followed_id'];
     });
     $owners_id[] = $current_user_id;
     //        $privacy = Privacy::where('name',"Công khai")->get()->first();
     $entries = Entry::whereIn('user_id', $owners_id)->where('privacy', 1)->orWhere('user_id', $current_user_id)->orderBy('updated_at', 'DESC')->paginate($this->entries_per_page);
     $left_albums = Album::whereIn('user_id', $owners_id)->where('privacy', 1)->orWhere('user_id', $current_user_id)->orderBy('updated_at', 'DESC')->get();
     //        $datas = array();
     //
     //        foreach ($entries as $index => $entry) {
     //            if (FEUsersHelper::isCurrentUser($entry->user_id)) {
     //                if($this->getEntry($entry->entry_id, $entry->type, null)){
     //                    $datas[] = $this->getEntry($entry->entry_id, $entry->type, null);
     //                }
     //            } else{
     //                if($this->getEntry($entry->entry_id, $entry->type, $privacy->id)){
     //                    $datas[] = $this->getEntry($entry->entry_id, $entry->type, $privacy->id);
     //                }
     //
     //            }
     //        }
     ////        $datas = $this->pagination($datas, 3, $page);
     $suggests = FEUsersHelper::getSuggestes();
     return array('datas' => $entries, 'suggestes' => $suggests, 'left_albums' => $left_albums);
 }