public function lookupWinner($itemid)
 {
     $winner = Winner::where('itemid', $itemid)->first();
     if ($winner != null) {
         $luckyWinner = Participant::where('id', $winner->participantid)->first();
         $array = array('success' => true, 'winner' => $luckyWinner);
         return json_encode($array);
     } else {
         $array = array('success' => false, 'message' => "NO WINNER CHOSEN");
         return json_encode($array);
     }
 }
Пример #2
0
                    $luckyWinner = $lucky->winner;
                    //verify that the item has not been won//
                    if ($luckyWinner != "Winner already chosen") {
                        //get the winner's personal info to pass back with the winning ticket info//
                        $luckyParticipant = Participant::where('id', $luckyWinner->participantid)->first();
                        $array = array('success' => true, 'ticket' => $ticket, 'participant' => $luckyParticipant);
                        echo json_encode($array);
                    } else {
                        $array = array('success' => false, 'message' => "Winner already chosen");
                        echo json_encode($array);
                    }
                } else {
                    $array = array('success' => false, 'message' => "NO TICKETS PURCHASED!!");
                    echo json_encode($array);
                }
            } else {
                $array = array('success' => false, 'message' => "WRONG HOST");
                echo json_encode($array);
            }
        } else {
            $array = array('success' => false, 'message' => "NO ITEM FOUND!");
            echo json_encode($array);
        }
    });
    //look up the winner for an item//
    $app->get('/winner/:itemid/', $authorize(), function ($itemid) use($app, $resourceServer) {
        $winner = new Winner();
        $json = $winner->lookupWinner($itemid);
        echo $json;
    });
});