/** * Store a newly created resource in storage. * * @return Response */ public function store(LikeRequest $request) { $input = $request->all(); $like = new Like($input); $like->save(); $notification = new RepostNotification(); $notification->user_id = Auth::user()->id; $notification->my_user_id = Tweet::find($like->tweet_id)->user->id; $notification->tweet_id = $like->tweet_id; $notification->type = "Like"; $notification->reply_id = 0; $notification->save(); return redirect()->back(); }
public function repost($tweet_id, $user_id) { $post = Tweet::find($tweet_id); $repost = new Tweet(); $repost->tweet_id = $tweet_id; $repost->tweet = $post->tweet; $repost->user_id = $user_id; $repost->original_tweet_id = 0; $repost->save(); $notification = new RepostNotification(); $notification->user_id = Auth::user()->id; $notification->my_user_id = Tweet::find($tweet_id)->user->id; $notification->tweet_id = $tweet_id; $notification->reply_id = 0; $notification->type = "Repost"; $notification->save(); return redirect('/' . Auth::user()->username); }
/** * Display a listing of the resource. * * @return Response */ public function index() { $notifications = RepostNotification::where('my_user_id', Auth::user()->id)->get()->reverse(); return view('notifications', compact('notifications')); }