public function CreateUser($information) { // The regisration object which will hold the results of the function $regisration = array(); $regisration['status'] = true; // Check to see if account already exists if (UserModel::where('username', '=', $information['username'])->exists() || UserModel::where('email_address', '=', $information['emailAddress'])->exists()) { $regisration['status'] = false; $regisration['message'] = "account already exists"; return $regisration; } // Create user first $user = new UserModel(); $user->username = $information['username']; $user->password = Hash::make($information['password']); $user->first_name = $information['firstName']; $user->last_name = $information['lastName']; $user->email_address = $information['emailAddress']; $user->save(); // Create financial records $finance = new FinanceModel(); $finance->account_id = $account->account_id; $finance->finance_type = "paypal"; $finance->balance = 0.0; $finance->save(); return $regisration; }
public function RefundTicket($userId, $ticketId) { $return = array(); $return['status'] = true; // Get the raffle information from the ticket $ticket = TicketModel::find($ticketId); // Decrement the current number of tickets column for the raffle $ticket->raffle->current_num_tickets--; $ticket->raffle->save(); // Refund the ticket price to the users account $user = UserModel::find($userId); $user->finance->balance = $user->finance->balance + $ticket->raffle->ticket_price; $user->finance->save(); // Delete the ticket ( acutally setting the isDeleted to true) $ticket->is_deleted = 1; $ticket->save(); return $return; }