<?php
  
  namespace Api\Controllers;
  
  use Api\Core\Controller;
  use Api\Services\UserService;
  use PDO;
  
  class VoteLinkController extends Controller
  {
    public function index()
    {
      $links = db()->query('SELECT * FROM VoteLinks');
      $links = $links->fetchAll(PDO::FETCH_ASSOC);
      
      if (_get('username')) {
        for ($i = 0; $i < count($links); $i++) {
          $links[$i]["link"] .= "?username=" . _get('username');
        }
      }
      
      response()->json($links);
    }
  }