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); }
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'); }
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; }