/**
  * Show the form for creating a new resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function create($id)
 {
     //add auction to watchlist
     $watchlist = new Watchlist();
     $watchlist->user_id = Auth::user()->id;
     $watchlist->art_id = $id;
     $watchlist->save();
     return redirect()->back()->withSuccess('added to watchlist');
 }
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     $this->validate($request, ['id' => 'required']);
     $data = $request->all();
     $existing = Watchlist::where('user_id', Auth::user()->id)->where('auction_id', $data['id'])->first();
     if (!$existing) {
         $watchlist = new Watchlist();
         $watchlist->user_id = Auth::user()->id;
         $watchlist->auction_id = $data['id'];
         $watchlist->save();
     }
     $locale = App::getLocale();
     $watchlists = Auction::join('watchlist', 'watchlist.auction_id', '=', 'auctions.id')->where('watchlist.user_id', Auth::User()->id)->translatedIn($locale)->get();
     $newest = Auction::translatedIn($locale)->where('end_date', '>=', Carbon::now())->orderBy('created_at', 'DESC')->first();
     return view('watchlist.index', array('auctions' => $watchlists, 'newest' => $newest));
 }
Exemplo n.º 3
0
 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index()
 {
     //
     //        $name = Auth::user()->email;
     //        return view('dashboard');
     $user = Auth::user()->name;
     $userId = Auth::user()->id;
     $locateInDbUser = App\User::find($userId);
     $locateInDbItems = App\Items::find($userId);
     $locateInDbWatchlist = App\Watchlist::find($userId);
     $itemsWatched = DB::table('watchlists')->where('user_id', '=', $userId)->count();
     $itemsOwned = DB::table('items')->where('users_id', '=', $userId)->count();
     $benefit = $locateInDbUser->benefits;
     $auction_wins = $locateInDbUser->auction_wins;
     $itemsOnWatchlist = DB::table('watchlists')->where('user_id', '=', $userId)->get();
     if ($itemsOnWatchlist == []) {
         $queryWatchlist = '';
         return view('dashboard')->with('user', $user)->with('userId', $userId)->with('benefits', $benefit)->with('auction_wins', $auction_wins)->with('itemsWatched', $itemsWatched)->with('itemsOwned', $itemsOwned)->with('itemsOnWatchlist', $itemsOnWatchlist)->with('queryWatchlist', $queryWatchlist);
     } else {
         $queryWatchlist = DB::table('items');
         foreach ($itemsOnWatchlist as $itemOnWatchlist) {
             $queryWatchlist->orWhere('id', '=', $itemOnWatchlist->item_id);
         }
         $queryWatchlist = $queryWatchlist->get();
         //        return $queryWatchlist;
         return view('dashboard')->with('user', $user)->with('userId', $userId)->with('benefits', $benefit)->with('auction_wins', $auction_wins)->with('itemsWatched', $itemsWatched)->with('itemsOwned', $itemsOwned)->with('itemsOnWatchlist', $itemsOnWatchlist)->with('queryWatchlist', $queryWatchlist);
     }
 }
Exemplo n.º 4
0
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store($id)
 {
     $auction = Auction::findOrFail($id);
     $watcher = Auth::user();
     $watchlist = Watchlist::firstOrNew(array('user_id' => $watcher->id, 'auction_id' => $auction->id));
     $watchlist->save();
     return Redirect::route('watchlist.my');
 }
Exemplo n.º 5
0
 public function myWatchlist()
 {
     if (Auth::check() && Watchlist::where('user_id', Auth::user()->id)->where('art_id', $this->id)->exists()) {
         return true;
     } else {
         return false;
     }
 }
 public function addToWatchlist($id)
 {
     $watchlistcheck = Watchlist::where('FK_auction_id', '=', $id)->where('FK_user_id', '=', Auth::user()->id)->first();
     $newestAuction = Auction::where('FK_status_id', '=', 1)->orWhere('FK_status_id', '=', 3)->orderBy('created_at', 'desc')->first();
     if ($watchlistcheck == null) {
         $newWatchlist = new Watchlist();
         $newWatchlist->FK_user_id = Auth::user()->id;
         $newWatchlist->FK_auction_id = $id;
         $newWatchlist->save();
         $watchlist = Watchlist::where('FK_user_id', '=', Auth::user()->id)->get();
         $success = 'You successfully added an auction to your watchlist!';
         return view('watchlist')->with('watchlist', $watchlist)->with('newestAuction', $newestAuction)->with('success', $success);
     } else {
         $watchlist = Watchlist::where('FK_user_id', '=', Auth::user()->id)->get();
         $warning = 'This auction was already added to your watchlist!';
         return view('watchlist')->with('watchlist', $watchlist)->with('newestAuction', $newestAuction)->with('warning', $warning);
     }
 }
 public function delete(Request $request)
 {
     $deletes = $request->deletes;
     foreach ($deletes as $delete) {
         Watchlist::whereRaw('id = ' . $delete . ' AND user_id = ' . Auth::user()->id)->delete();
     }
     Session::flash('flash_message', trans('auctions.watchlist.deleted'));
     return redirect()->back();
 }
Exemplo n.º 8
0
 public function getEndedWatchlist($id)
 {
     $watchlist = Watchlist::where(['user_id' => $id])->whereHas('auction', function ($q) {
         $q->where('expired', true);
     })->get();
     if (count($watchlist) > 0) {
         return $watchlist;
     } else {
         return false;
     }
 }
 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index()
 {
     //
     $user = Auth::user()->name;
     $userId = Auth::user()->id;
     $locateInDbUser = App\User::find($userId);
     $locateInDbItems = App\Items::find($userId);
     $locateInDbWatchlist = App\Watchlist::find($userId);
     $itemsWatched = DB::table('watchlists')->where('user_id', '=', $userId)->count();
     $itemsSelect = DB::table('items')->where('betting_status', '=', 1)->where('users_id', '=', $userId)->orderBy('id', 'asc')->lists('item_name');
     $itemsOwned = DB::table('items')->where('users_id', '=', $userId)->count();
     $benefit = $locateInDbUser->benefits;
     $auction_wins = $locateInDbUser->auction_wins;
     return view('retrieveOffer')->with('user', $user)->with('userId', $userId)->with('benefits', $benefit)->with('auction_wins', $auction_wins)->with('itemsWatched', $itemsWatched)->with('itemsOwned', $itemsOwned)->with('itemsSelect', $itemsSelect);
 }
Exemplo n.º 10
0
 protected function auctionDeleted($id)
 {
     $auction = Auction::find($id);
     $bids = Bid::where('auction_id', $id)->get();
     $watches = Watchlist::where('auction_id', $id)->get();
     $recipients = [];
     foreach ($bids as $bid) {
         if (!in_array($bid->bidder_id, $recipients)) {
             $recipients[] = $bid->bidder_id;
         }
     }
     foreach ($watches as $watch) {
         if (!in_array($watch->user_id, $recipients)) {
             $recipients[] = $watch->user_id;
         }
     }
     foreach ($recipients as $recipient) {
         $message = ['title' => 'Auction for ' . $auction->title . ' closed.', 'message' => 'We regret to inform you that the owner of ' . $auction->title . ' has closed the auction. This means that the work will not be sold and that no further bidding will be possible.', 'opened' => null, 'archived' => 0, 'user_id' => $recipient, 'sender_id' => 1];
         self::create($message);
     }
 }
Exemplo n.º 11
0
 public function show($lang, $slug)
 {
     $auction = Auction::findExtended(['slug' => $slug]);
     $watched = isset(Watchlist::where(['user_id' => Auth::user()->id, 'auction_id' => $auction->id])->first()->id);
     return view('auctions.show')->with(['auction' => $auction, 'watched' => $watched]);
 }
Exemplo n.º 12
0
 public static function removeAuctionFromWatchlist($auction_id = -1, $user_id = -1)
 {
     return Watchlist::where(['auction_id' => $auction_id, 'user_id' => $user_id])->delete();
 }
Exemplo n.º 13
0
 public function FinalItembet($idItem)
 {
     $user = Auth::user()->name;
     $userId = Auth::user()->id;
     $locateInDbUser = App\User::find($userId);
     $locateInDbItems = App\Items::find($userId);
     $locateInDbWatchlist = App\Watchlist::find($userId);
     $itemId = explode('X', $idItem);
     $itemId = intval($itemId[0]);
     $itemsWatched = DB::table('watchlists')->where('user_id', '=', $userId)->count();
     $itemsName = DB::table('items')->where('id', '=', $itemId)->value('item_name');
     $itemsDescription = DB::table('items')->where('id', '=', $itemId)->value('description');
     $itemsMin = DB::table('items')->where('id', '=', $itemId)->value('minimalPrice');
     $itemsOwned = DB::table('items')->where('users_id', '=', $userId)->count();
     $benefit = $locateInDbUser->benefits;
     $auction_wins = $locateInDbUser->auction_wins;
     //
     return view('FinalItembet')->with('user', $user)->with('userId', $userId)->with('benefits', $benefit)->with('auction_wins', $auction_wins)->with('itemsWatched', $itemsWatched)->with('itemsOwned', $itemsOwned)->with('itemsDescription', $itemsDescription)->with('itemsMin', $itemsMin)->with('itemId', $itemId)->with('itemsName', $itemsName);
 }
 /**
  * Store a newly created resource in storage.
  *
  * @return \Illuminate\Http\Response
  */
 public function store($id)
 {
     Watchlist::create(['user_id' => Auth::user()->id, 'auction_id' => $id]);
     return redirect('/watchlist');
 }
Exemplo n.º 15
0
 public function searchItemForm()
 {
     $itemToSearchName = Input::get('itemName');
     $itemToSearchSelect = Input::get('userChosen');
     $itemToSearchSelect2 = Input::get('categoryChosen');
     $user = Auth::user()->name;
     $userId = Auth::user()->id;
     //            $itemsToId=DB::table('items')
     //                ->where('item_name','=',$itemToOffer)
     //                ->where('users_id','=',$userId)
     //                ->first();
     $query = DB::table('items');
     $query->where('users_id', '<>', $userId);
     $query->where('betting_status', '=', 1);
     if ($itemToSearchSelect != 'Any user') {
         //                $query->where('user')
         $usersSelect = DB::table('users')->where('email', '=', $itemToSearchSelect)->first();
         $query->where('users_id', '=', $usersSelect->id);
     }
     if ($itemToSearchSelect2 != 'Any category') {
         //                $query->where('user')
         //            $catSelect=DB::table('categories')
         //                ->where('catname','=',$itemToSearchSelect2)
         //                ->first();
         $query->where('category1', '=', $itemToSearchSelect2);
     }
     if ($itemToSearchName != '') {
         $query->where('item_name', 'LIKE', '%' . $itemToSearchName . '%');
     }
     $rows = $query->get();
     if ($rows == []) {
         Session::flash('messageErrorDate', "No match, redefine your search terms");
         return redirect('searchItem');
     } else {
         $rows = $query->paginate(10);
         $user = Auth::user()->name;
         $userId = Auth::user()->id;
         $locateInDbUser = App\User::find($userId);
         $locateInDbItems = App\Items::find($userId);
         $locateInDbWatchlist = App\Watchlist::find($userId);
         $itemsWatched = DB::table('watchlists')->where('user_id', '=', $userId)->count();
         $usersTable = DB::table('users');
         $itemsOwned = DB::table('items')->where('users_id', '=', $userId)->count();
         $benefit = $locateInDbUser->benefits;
         $auction_wins = $locateInDbUser->auction_wins;
         Session::flash('messageOkSearch', "");
         return view('searchResults')->with('user', $user)->with('userId', $userId)->with('benefits', $benefit)->with('auction_wins', $auction_wins)->with('itemsWatched', $itemsWatched)->with('itemsOwned', $itemsOwned)->with('rowsSearch', $rows)->with('usersTable', $usersTable);
     }
     //        return $rows;
 }
 public function deletewatchlist()
 {
     $checked = Input::get('checkbox');
     if (is_array($checked)) {
         Watchlist::destroy($checked);
     }
     return Redirect::back();
 }
Exemplo n.º 17
0
 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function index()
 {
     $watch = Watchlist::where('uw_usr_id', Auth::user()->id)->join('film', 'user_watchlist.uw_fl_id', '=', 'film.fl_id')->orderBy('uw_id', 'desc')->paginate(10);
     return view('watchlist.index', compact('watch'));
 }