105 lines
4.5 KiB
PHP
105 lines
4.5 KiB
PHP
<?php
|
|
|
|
namespace App\Filament\Resources\Skills\Schemas;
|
|
|
|
use App\Models\Skill;
|
|
use Filament\Forms\Components\Select;
|
|
use Filament\Forms\Components\Textarea;
|
|
use Filament\Forms\Components\TagsInput;
|
|
use Filament\Forms\Components\TextInput;
|
|
use Filament\Forms\Components\Toggle;
|
|
use Filament\Schemas\Components\Section;
|
|
use Filament\Schemas\Schema;
|
|
use Illuminate\Support\Str;
|
|
|
|
class SkillForm
|
|
{
|
|
public static function configure(Schema $schema): Schema
|
|
{
|
|
return $schema
|
|
->columns(3)
|
|
->components([
|
|
Section::make('Details')
|
|
->columnSpan(2)
|
|
->components([
|
|
TextInput::make('name')
|
|
->required()
|
|
->live(onBlur: true)
|
|
->afterStateUpdated(function (string $operation, $state, callable $set) {
|
|
if ($operation === 'create') {
|
|
$set('slug', Str::slug($state));
|
|
}
|
|
}),
|
|
TextInput::make('slug')
|
|
->required()
|
|
->unique(Skill::class, 'slug', ignoreRecord: true)
|
|
->helperText('Used in the URL, e.g. /skills/your-slug'),
|
|
Textarea::make('description')
|
|
->required()
|
|
->rows(4)
|
|
->columnSpanFull(),
|
|
TextInput::make('url')
|
|
->label('Repository / homepage URL')
|
|
->url()
|
|
->required(),
|
|
TextInput::make('docs_url')
|
|
->label('Documentation URL')
|
|
->url(),
|
|
TextInput::make('logo_url')
|
|
->label('Logo URL')
|
|
->url(),
|
|
Textarea::make('install_instructions')
|
|
->label('Install instructions')
|
|
->rows(2)
|
|
->helperText('e.g. Copy into ~/.claude/skills/ and restart Claude')
|
|
->columnSpanFull(),
|
|
Textarea::make('example_prompt')
|
|
->label('Example prompt')
|
|
->rows(2)
|
|
->helperText('A sample prompt that would trigger or use this skill')
|
|
->columnSpanFull(),
|
|
TagsInput::make('tags')
|
|
->placeholder('Add a tag and press enter')
|
|
->helperText('e.g. official, anthropic, community')
|
|
->columnSpanFull(),
|
|
]),
|
|
Section::make('Classification')
|
|
->columnSpan(1)
|
|
->components([
|
|
Select::make('category')
|
|
->options(config('skills.categories'))
|
|
->required()
|
|
->searchable(),
|
|
TextInput::make('requirements')
|
|
->helperText('e.g. Claude Code, Code Execution tool'),
|
|
]),
|
|
Section::make('Moderation')
|
|
->columnSpan(3)
|
|
->columns(4)
|
|
->components([
|
|
Toggle::make('approved')
|
|
->helperText('Only approved skills are shown publicly.')
|
|
->default(false),
|
|
Toggle::make('featured')
|
|
->helperText('Highlight this skill.')
|
|
->default(false),
|
|
Select::make('user_id')
|
|
->label('Submitted by')
|
|
->relationship('user', 'name')
|
|
->searchable()
|
|
->preload(),
|
|
TextInput::make('views')
|
|
->numeric()
|
|
->default(0)
|
|
->disabled()
|
|
->dehydrated(),
|
|
TextInput::make('clicks')
|
|
->numeric()
|
|
->default(0)
|
|
->disabled()
|
|
->dehydrated(),
|
|
]),
|
|
]);
|
|
}
|
|
}
|