summaryrefslogtreecommitdiff
path: root/src/Controller/Home.php
blob: 1c1500ccbf952e32c10d5029abce6d3311f222fa (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
<?php

namespace Elements\Controller;

use Elements\DB;
use Elements\Model\Card;
use Elements\Template;

class Home
{
  public static function index()
  {
    $c = DB::$entityManager->getRepository(Card::class)->findOneBy([], ['id' => 'DESC']);
    echo "<pre>";
    $c && var_dump(
      array_map(fn ($item) => [$item->key, $item->value], $c->meta->toArray()),
      array_map(fn ($item) => "<img style='max-width: 100%;max-height:300px;' src='$item->path'> Votes: " . $item->getVotesTotal(), $c->artworks->toArray()),
      array_map(fn ($item) => $item->value, $c->votes->toArray()),
      'Votes: ' . $c->getVotesTotal(),
    );

    return Template::render('home.twig', [
      'fields' => [
	'name' => 'meta[name]',
	'converted mana cost' => 'meta[cmc]',
	'is uno reverse' => 'meta[is_uno_reverse]',
      ],
    ]);
  }
}