Beispiel #1
0
 public function buy($price)
 {
     $art->sold = 1;
     $art->sold_for = $art->price;
     $art->sold_to = Auth::user()->id;
     $art->save();
     Bid::where('art_id', $art_id)->delete();
     watchlist::where('art_id', $art_id)->delete();
 }
Beispiel #2
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();
     }
 }
Beispiel #3
0
 public function myWatchlist()
 {
     $list = watchlist::where('watchlists.user_id', Auth::user()->id)->join('arts', 'arts.id', '=', 'watchlists.art_id')->paginate(12);
     return View('profile.watchlist', compact('list'));
 }