add invites!
parent
a8a1d48f10
commit
c53e790fb7
@ -1,15 +0,0 @@
|
||||
#!/usr/bin/env php
|
||||
<?php
|
||||
|
||||
$basedir = realpath(__DIR__ . '/../');
|
||||
# All calls are now relative to the root directory
|
||||
chdir($basedir);
|
||||
|
||||
include $basedir . '/vendor/autoload.php';
|
||||
|
||||
$core = new \Eater\Glim\Core();
|
||||
$core->startTimer(["total"]);
|
||||
$core->boot($basedir);
|
||||
echo $core->get('user')->createInvite();
|
||||
$core->endTimer(["total"]);
|
||||
|
@ -0,0 +1,29 @@
|
||||
<?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()
|
||||
]);
|
||||
}
|
||||
}
|
@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace Eater\Glim\Handler\Panel\Invites;
|
||||
|
||||
|
||||
use Eater\Glim\Handler\Session;
|
||||
use Eater\Glim\Service\User;
|
||||
use Aura\Session\Segment;
|
||||
|
||||
class Create extends Session
|
||||
{
|
||||
public function handle()
|
||||
{
|
||||
/** @var User $user */
|
||||
$user = $this->get('user');
|
||||
|
||||
$userModel = $this->getUser();
|
||||
|
||||
if ($userModel->getUsedInvites() < $userModel->getMaxInvites() || $userModel->getMaxInvites() === -1) {
|
||||
$user->createInvite($userModel);
|
||||
} else {
|
||||
/** @var Segment $segment */
|
||||
$segment = $this->get('session')->getSegment('main');
|
||||
$segment->setFlash('error', 'You dont have any invites anymore');
|
||||
}
|
||||
|
||||
return $this->redirect('/panel/invites');
|
||||
}
|
||||
}
|
@ -0,0 +1,48 @@
|
||||
{% extends "base_bootstrap.html.twig" %}
|
||||
|
||||
{% block content %}
|
||||
<div class="container">
|
||||
<div class="row">
|
||||
<h2 id="certificates">Invites <small>You used {{ used_invites }} from your {{ max_invites == -1 ? 'infinite' : max_invites }} invites</small></h2>
|
||||
</div>
|
||||
{% if error %}
|
||||
<div class="row">
|
||||
<div class="alert alert-warning" role="alert">
|
||||
{{ error }}
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
<div class="row">
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Invite</th>
|
||||
<th>
|
||||
{% if max_invites > used_invites or max_invites == -1 %}
|
||||
<form action="/panel/invites/create" method="post">
|
||||
<button class="btn btn-default pull-right" type="submit">Create new invite</button>
|
||||
</form>
|
||||
{% endif %}
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for invite in invites %}
|
||||
<tr>
|
||||
<td>
|
||||
<kbd>{{ invite.getInvite() }}</kbd>
|
||||
</td>
|
||||
<td>
|
||||
<button class="btn btn-default">Copy</button>
|
||||
</td>
|
||||
</tr>
|
||||
{% else %}
|
||||
<tr>
|
||||
<td colspan="2">You don't have any invites :(</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
Loading…
Reference in New Issue