Esempio n. 1
0
 public function index()
 {
     $tweet_all = Tweet::all();
     $follow_all = Follow::all();
     $user_follow = $follow_all->filter(function ($item) {
         return $item['user_id'] == Auth::user()->id;
     })->pluck('follow_id');
     $data['tweets'] = $tweet_all;
     $data['followed'] = $user_follow->toArray();
     return view('tweet/home', $data);
 }
Esempio n. 2
0
 public function checkFollow($id)
 {
     if (Auth::user()->id != $id) {
         $follow = Follow::all();
         if ($follow->where('user_id', Auth::user()->id)->where('follow_id', (int) $id)->isEmpty()) {
             $this->_follow($id);
         } else {
             $this->_unfollow($id);
         }
     }
     return redirect('tweet');
 }
Esempio n. 3
0
 public function followed_by()
 {
     $follows = Follow::all();
     $user_ids_array = [];
     foreach ($follows as $f) {
         if ($f->followed_user_id == $this->id) {
             $user_ids_array[] = $f->follower_id;
         }
     }
     return $user_ids_array;
 }