Вложения к записям, профилировщик запросов, приём вебхуков по токену

This commit is contained in:
rsgrinko committed 2026-09-15 23:48:18 +03:00
1 parent a75f27f3ed
commit e42404ebe0
33 files changed
+1494 -124

No files matched your search

+2 -2
View File
@@ -39,8 +39,8 @@ $action = $isNew
<?php } ?>
<label>
<span>Файл<?= $note->hasFile() ? ' (сейчас: ' . View::e((string) $note->raw('file_name')) . ')' : '' ?></span>
<input type="file" name="attachment">
<span>Файлы (можно несколько)</span>
<input type="file" name="attachment[]" multiple>
</label>
<div class="row">
+33
View File
@@ -7,6 +7,7 @@ declare(strict_types=1);
*
* @var \App\Models\Note $note
* @var \Rsgrinko\Proton\Models\User|null $author
* @var array<int, \Rsgrinko\Proton\Files\Attachment> $attachments
*/
use Rsgrinko\Proton\Support\SignedUrl;
@@ -75,6 +76,38 @@ use Rsgrinko\Proton\View\View;
</div>
</div>
<?php if ($attachments !== []) { ?>
<div class="card">
<h2>Вложения (<?= count($attachments) ?>)</h2>
<div class="attachments">
<?php foreach ($attachments as $attachment) { ?>
<?php $url = View::route('notes.attachment', ['id' => $note->id(), 'attachment' => $attachment->id()]); ?>
<div class="attachment">
<a href="<?= View::e($url) ?>">
<?php if ($attachment->isImage()) { ?>
<img src="<?= View::e($url) ?>" alt="<?= View::e((string) $attachment->raw('name')) ?>">
<?php } else { ?>
<span class="file-icon"><?= View::e(strtoupper(pathinfo((string) $attachment->raw('name'), PATHINFO_EXTENSION)) ?: 'файл') ?></span>
<?php } ?>
</a>
<div class="small break"><?= View::e((string) $attachment->raw('name')) ?></div>
<div class="muted small"><?= View::e($attachment->readableSize()) ?></div>
<?php if (View::can('note.edit', $note)) { ?>
<form method="post" action="<?= View::e(View::route('notes.detach', ['id' => $note->id()])) ?>">
<?= View::csrf() ?>
<input type="hidden" name="attachment" value="<?= $attachment->id() ?>">
<button type="submit" class="small danger" data-confirm="Убрать вложение? Файл удалится.">Убрать</button>
</form>
<?php } ?>
</div>
<?php } ?>
</div>
</div>
<?php } ?>
<?= View::partial('history', ['entity' => 'note', 'id' => $note->id()]) ?>
<p><a href="<?= View::e(View::route('notes.index')) ?>">← ко всем заметкам</a></p>