$app->post('/logout', function () use($app, $db) { $email = $app->request->post('email'); $user = $db->users()->where('email', $email); if ($user->fetch()) { $token = ''; $data = ['token' => $token]; $result = $user->update($data); echo "You have logged off successfully"; } else { echo json_encode(array('status' => false, 'message' => 'Please verify your email')); } }); // Get all emojis $app->get('/emojis', function () use($app, $db) { $emojis = array(); foreach ($db->emojis() as $emoji) { $emojis[] = array('id' => $emoji['id'], 'name' => $emoji['name'], 'keywords' => $emoji['keywords'], 'emoji' => $emoji['emoji'], 'category' => $emoji['category'], 'created_at' => $emoji['created_at'], 'updated_at' => $emoji['updated_at'], 'user' => $emoji['user']); } $app->response()->header('Content-Type', 'application/json'); echo json_encode($emojis, JSON_FORCE_OBJECT); }); // Get a single emoji $app->get('/emojis/:id', function ($id) use($app, $db) { $app->response()->header('Content-Type', 'application/json'); $emoji = $db->emojis()->where('id', $id); if ($data = $emoji->fetch()) { echo json_encode(array('id' => $data['id'], 'name' => $data['name'], 'keywords' => $data['keywords'], 'emoji' => $data['emoji'], 'category' => $data['category'], 'created_at' => $data['created_at'], 'updated_at' => $data['updated_at'], 'user' => $data['user'])); } else { echo json_encode(array('status' => false, 'message' => "Emoji ID {$id} does not exist")); } });