public function getParticipants($eventid)
 {
     $participant = Participant::where('eventid', $eventid)->get();
     if ($participant == null) {
         $array = array('success' => false, 'message' => 'No participants found');
         return json_encode($array);
     }
     $array = array('success' => true, 'participant' => $participant);
     return json_encode($array);
 }
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store()
 {
     $input = Input::all();
     $conversation = Conversation::create(['subject' => $input['subject']]);
     $message = Message::create(['conversation_id' => $conversation->id, 'user_id' => Auth::user()->id, 'body' => $input['message']]);
     $sender = Participant::create(['conversation_id' => $conversation->id, 'user_id' => Auth::user()->id]);
     if ($this->input->has('recipient')) {
         $recipient = User::where('email', $input['recipient'])->first();
         Participant::create(['conversation_id' => $conversation->id, 'user_id' => $recipient->id]);
     }
     return Redirect::route('conversations.index');
 }
 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);
     }
 }
<?php

use Models\Participant;
use Lib\OAuth2\OAuth2;
$app->group('/participant', function () use($app, $authorize, $resourceServer) {
    //create participant to own an order//
    $app->post('/', $authorize(), function () use($app, $resourceServer) {
        $participant = new Participant();
        $eventid = $app->request->post('eventid');
        $name = $app->request->post('name');
        $email = $app->request->post('email');
        $phone = $app->request->post('phone');
        $orderid = $app->request->post('orderid');
        //perform insertion//
        $json = $participant->addParticipant($eventid, $name, $email, $phone, $orderid);
        echo $json;
    });
    //get participants for an event//
    $app->get('/participants/event/:eventid/', $authorize(), function ($eventid) use($app, $resourceServer) {
        $participant = new Participant();
        $json = $participant->getParticipants($eventid);
        echo $json;
    });
});
     //get currently logged on host//
     $userid = $resourceServer->getAccessToken()->getSession()->getOwnerId();
     //verify that current host owns the event of the item//
     if ($event->verifyHost($item->eventid, $userid)) {
         //pick a random ticket//
         if (sizeof($tickets) > 0) {
             $numTix = sizeof($tickets);
             $luckyNum = mt_rand(0, $numTix);
             $ticket = $tickets[$luckyNum];
             //more messy json conversions...//
             $lucky = json_decode($winner->pickWinner($itemid, $ticket['participantid']));
             $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 {