Files
larablog/app/Filament/Resources/Attachments/Schemas/AttachmentForm.php
T
ak 263b98b218 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.
2026-08-12 01:15:38 +08:00

55 lines
2.0 KiB
PHP

<?php
declare(strict_types=1);
namespace App\Filament\Resources\Attachments\Schemas;
use Filament\Forms\Components\FileUpload;
use Filament\Forms\Components\Select;
use Filament\Forms\Components\TextInput;
use Filament\Schemas\Schema;
class AttachmentForm
{
public static function configure(Schema $schema): Schema
{
$disk = config('larablog.attachments_disk', 'attachments');
$mimes = config('larablog.allowed_attachment_mimes', []);
return $schema
->components([
Select::make('article_id')
->label(__('admin.fields.article'))
->relationship('article', 'title')
->searchable()
->preload(),
FileUpload::make('upload')
->label(__('admin.fields.upload'))
->disk($disk)
->directory(fn (): string => 'uploads/'.now()->format('Y/m'))
->visibility('public')
->acceptedFileTypes($mimes)
->maxSize(20480)
->required(fn (string $operation): bool => $operation === 'create')
->dehydrated(fn ($state): bool => filled($state))
->helperText(__('admin.helpers.attachment_upload')),
TextInput::make('filename')
->label(__('admin.fields.filename'))
->maxLength(255),
TextInput::make('visibility')
->label(__('admin.fields.visibility'))
->default('public')
->required(),
TextInput::make('legacy_filepath')
->label(__('admin.fields.legacy_filepath'))
->maxLength(255),
TextInput::make('downloads')
->label(__('admin.fields.downloads'))
->numeric()
->default(0)
->disabled()
->dehydrated(),
]);
}
}