Initial baseline: LaraBlog core with plugin commerce surface.

Captures the current working tree after theme slots, ArticleAccess, and the payment / paid-content plugins so subsequent work has a reviewable git history.
This commit is contained in:
ak
2026-08-12 01:15:38 +08:00
commit 263b98b218
337 changed files with 31393 additions and 0 deletions
@@ -0,0 +1,49 @@
<?php
declare(strict_types=1);
namespace App\Filament\Resources\Attachments\Pages;
use App\Filament\Resources\Attachments\AttachmentResource;
use Filament\Resources\Pages\CreateRecord;
use Illuminate\Support\Facades\Storage;
class CreateAttachment extends CreateRecord
{
protected static string $resource = AttachmentResource::class;
/**
* @param array<string, mixed> $data
* @return array<string, mixed>
*/
protected function mutateFormDataBeforeCreate(array $data): array
{
$disk = config('larablog.attachments_disk', 'attachments');
$path = $data['upload'] ?? null;
unset($data['upload']);
if (! is_string($path) || $path === '') {
throw new \InvalidArgumentException(__('admin.messages.upload_required'));
}
$storage = Storage::disk($disk);
$mime = method_exists($storage, 'mimeType') ? ($storage->mimeType($path) ?: null) : null;
$allowed = config('larablog.allowed_attachment_mimes', []);
if (is_string($mime) && $allowed !== [] && ! in_array($mime, $allowed, true)) {
$storage->delete($path);
throw new \InvalidArgumentException(__('admin.messages.mime_not_allowed', ['mime' => $mime]));
}
$data['disk'] = $disk;
$data['path'] = $path;
$data['filename'] = $data['filename'] ?: basename($path);
$data['mime'] = $mime;
$data['size'] = $storage->size($path) ?: 0;
$data['checksum'] = hash('sha256', (string) $storage->get($path));
$data['synced_at'] = now();
$data['visibility'] = $data['visibility'] ?? 'public';
$data['downloads'] = (int) ($data['downloads'] ?? 0);
return $data;
}
}
@@ -0,0 +1,26 @@
<?php
declare(strict_types=1);
namespace App\Filament\Resources\Attachments\Pages;
use App\Domain\Media\AttachmentStorageService;
use App\Filament\Resources\Attachments\AttachmentResource;
use App\Models\Attachment;
use Filament\Actions\DeleteAction;
use Filament\Resources\Pages\EditRecord;
class EditAttachment extends EditRecord
{
protected static string $resource = AttachmentResource::class;
protected function getHeaderActions(): array
{
return [
DeleteAction::make()
->before(function (Attachment $record, AttachmentStorageService $storage): void {
$storage->deleteFromDisk($record);
}),
];
}
}
@@ -0,0 +1,21 @@
<?php
declare(strict_types=1);
namespace App\Filament\Resources\Attachments\Pages;
use App\Filament\Resources\Attachments\AttachmentResource;
use Filament\Actions\CreateAction;
use Filament\Resources\Pages\ListRecords;
class ListAttachments extends ListRecords
{
protected static string $resource = AttachmentResource::class;
protected function getHeaderActions(): array
{
return [
CreateAction::make(),
];
}
}