Пример #1
0
 public function getCategories()
 {
     if (count($this->categories) == 0) {
         $this->categories = ItemCategory::categoriesForItem($this->id);
     }
     return $this->categories;
 }
Пример #2
0
 public function getSearch(Request $request, Session $session)
 {
     $searchTerm = $request->get['search-bar'];
     $auction_data = $this->getExactAuctionDataSearch(explode(" ", $searchTerm), $request);
     $auction_array = array();
     foreach ($auction_data as $value) {
         $auction = new Auction($value);
         if (new \DateTime() <= new \DateTime($auction->end_date)) {
             array_push($auction_array, $auction);
         }
     }
     $date = isset($request->get["date"]) ? $request->get["date"] : "0";
     $price = isset($request->get["price"]) ? $request->get["price"] : "0";
     $categories = ItemCategory::all();
     if (!empty($auction_data)) {
         return (new View('search', ["selectedCategories" => $request->get, "categories" => $categories, "auctionsFound" => true, "searchTerm" => $searchTerm, "auctionData" => $auction_data, "date" => $date, "price" => $price, "auction_array" => $auction_array]))->render();
     } else {
         return (new View('search', ["auctionsFound" => false, "searchTerm" => $searchTerm, "categories" => $categories, "selectedCategories" => $request->get]))->render();
     }
 }
Пример #3
0
 public function getCreateAuctionPage(Request $request, Session $session)
 {
     if (!$session->userIsLoggedIn()) {
         return $this->redirectTo('/login');
     }
     if (!$session->activeUser()->isSeller()) {
         return $this->redirectTo('/dashboard?error=' . urlencode('You must register as a seller to create an auction'));
     }
     return (new View('create_auction', ['user' => $session->activeUser(), 'item_categories' => ItemCategory::all()]))->render();
 }
Пример #4
0
 public function getHomepage(Request $request, Session $session)
 {
     $categories = ItemCategory::all();
     return (new View('home', ["categories" => $categories]))->render();
 }