Ejemplo n.º 1
0
 public function notification($art_id, $user_id)
 {
     $bidders = bid::where('bids.art_id', $art_id)->join('arts', 'arts.id', '=', 'bids.art_id')->where('bids.user_id', '<>', $user_id)->select('bids.user_id', 'arts.title')->get();
     foreach ($bidders as $bidder) {
         $input = new notification();
         $input->user_id = $bidder->user_id;
         $input->notification = $bidder->title . " is sold.";
         $input->save();
     }
     $watchlist = watchlist::where('watchlists.art_id', $art_id)->join('arts', 'arts.id', '=', 'watchlists.art_id')->where('watchlists.user_id', '<>', $user_id)->select('watchlists.user_id', 'arts.title')->get();
     foreach ($watchlist as $list) {
         $input = new notification();
         $input->user_id = $list->user_id;
         $input->notification = $list->title . " from your watchlist is sold.";
         $input->save();
     }
 }