<?php

namespace Eater\Glim\Handler\Panel;


use Aura\Session\Segment;
use Eater\Glim\Handler\Session;

class Invites extends Session
{
    protected $shouldHaveUser = true;

    public function handle()
    {
        $user = $this->getUser();

        $invites = $user->getInvites();

        /** @var Segment $segment */
        $segment = $this->get('session')->getSegment('main');

        return $this->render('panel/invites.html.twig', [
            'invites' => $invites,
            'error' => $segment->getFlash('error'),
            'used_invites' => $user->getUsedInvites(),
            'max_invites' => $user->getMaxInvites()
        ]);
    }
}