This commit is contained in:
Adrian Hopek
2022-04-22 12:41:00 +02:00
parent 7d12a1a153
commit fad4290cc3
33 changed files with 599 additions and 78 deletions

View File

@@ -0,0 +1,33 @@
<?php
declare(strict_types=1);
namespace Toby\Domain\Slack\Handlers;
use Spatie\SlashCommand\Attachment;
use Spatie\SlashCommand\Request;
use Spatie\SlashCommand\Response;
use Spatie\SlashCommand\Handlers\SignatureHandler;
use Toby\Eloquent\Models\Key;
class KeyList extends SignatureHandler
{
protected $signature = "toby klucze";
protected $description = "Lista wszystkich kluczy";
public function handle(Request $request): Response
{
$keys = Key::query()
->orderBy("id")
->get()
->map(fn(Key $key) => "Klucz nr {$key->id} - <@{$key->user->profile->slack_id}>");
return $this->respondToSlack("Lista kluczy")
->withAttachment(
Attachment::create()
->setColor('#3C5F97')
->setText($keys->implode("\n"))
);
}
}