Skip to content

neamtua/secret-santa

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 

Repository files navigation

secret-santa

A PHP/MySQL Secret Santa pairing class

Pieced this together to make a small website for me and my friends to draw for our anually Secret Santa event.

Usage

1. Setting up the database

Enter your database credentials in the class file and import the sql structure from secretsanta.sql

private $database = [
    'server' => '',
    'username' => '',
    'password' => '',
    'database' => ''
];

2. Include the class file

require_once 'SecretSanta.php';

3. Initialize the class

$secretSanta = new \neamtua\SecretSanta();

4. Start doing stuff

Generating pairs. The function will check if pairs have already been generated so it doesn't keep overriding them.

$secretSanta->generatePairs();

Get the list of people from the database. Use this to generate a dropdown for people to choose their name from and get their pairing.

$santas = $secretSanta->getListOfPeople();

Get the pairing of a user. Will only return the pairing the first time it's called for a specific user so that people will not be tempted to take a look at other people's santas.

$giftee = $secretSanta->showGiftee($santaId);

Reset the pairings. Use this for next year's draw.

$secretSanta->resetSantas();

5. Try not to peek at the pairings if you can :)

About

A PHP/MySQL Secret Santa pairing class

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages