nova resource builder

Nova Resource Builder

Safety Notice

This listing is imported from skills.sh public index metadata. Review upstream SKILL.md and repository scripts before running.

Copy this and send it to your AI assistant to learn

Install skill "nova resource builder" with this command: npx skills add hackur/web-standards-playground-showcase/hackur-web-standards-playground-showcase-nova-resource-builder

Nova Resource Builder

Build Nova 5.x resources following PCR Card's established patterns.

When to Use

  • Creating new Nova resources

  • Adding fields to existing resources

  • Implementing tab-based layouts

  • Configuring Badge/Select fields with constants

  • Setting up Nova search

Quick Commands

Create resource

php artisan nova:resource ResourceName

Validate Nova search configs

./scripts/dev.sh validate:nova-search

Clear Nova cache

./scripts/dev.sh nova:publish

PCR Card Nova Patterns

  1. Badge Fields (Closure Pattern)

CRITICAL: Badge fields use closures + hardcoded string maps, NOT constants.

use Laravel\Nova\Fields\Badge;

Badge::make('Status', function () { // Closure returns calculated value return $this->is_active ? 'active' : 'inactive'; }) ->map([ 'active' => 'success', // Hardcoded strings 'inactive' => 'danger', 'pending' => 'warning', ]) ->label(function ($value) { return match ($value) { 'active' => 'Active', 'inactive' => 'Inactive', 'pending' => 'Pending', }; });

  1. Select Fields (Constants Pattern)

Use constant class options() method:

use App\Constants\PromoCodeType; use Laravel\Nova\Fields\Select;

Select::make('Type') ->options(PromoCodeType::options()) // Returns ['fixed' => 'Fixed Amount', ...] ->displayUsingLabels() ->sortable() ->rules('required');

  1. Tab-Based Layouts

Use Tab::group() with Heading::make() for sections:

use Laravel\Nova\Tabs\Tab; use Laravel\Nova\Fields\Heading;

public function fields(NovaRequest $request): array { return [ ID::make()->sortable(),

    Tab::group('Resource Information', [
        Tab::make('Overview', [
            Heading::make('Basic Details'),
            Text::make('Name')->required(),

            Heading::make('Settings'),
            Boolean::make('Is Active'),
        ]),

        Tab::make('Details', [
            Heading::make('Additional Information'),
            Textarea::make('Description'),
        ]),
    ]),
];

}

Rules:

  • Use Tab::group('Title', [...]) for panel with heading

  • Use Heading::make('Name') for section dividers

  • NO Panel::make() inside tabs

  • HasMany relationships work in tabs

  1. Search Configuration

public static $search = [ 'id', 'name', 'user.email', // Relationship search 'submission.submission_number', ];

// REQUIRED: Eager load relationships public static $with = ['user', 'submission'];

Validate before commit:

./scripts/dev.sh validate:nova-search

Constants Reference

All constants follow this pattern:

class ConstantName { public const PREFIX_VALUE = 'value';

public static function all(): array;        // All values
public static function label(string $value): string;  // Human label
public static function options(): array;    // For Select fields
public static function isValid(string $value): bool;  // Validation

}

Available Constants (18 total):

  • App\Constants\PromoCodeType

  • TYPE_FIXED, TYPE_PERCENTAGE

  • App\Constants\ManualPaymentMethod

  • METHOD_CASH, METHOD_CHECK, etc.

  • App\Constants\ManualPaymentStatus

  • STATUS_PENDING, STATUS_VERIFIED, etc.

  • App\Constants\SubmissionState

  • DRAFT, SUBMITTED, RECEIVED, etc. (stores ::class refs)

  • App\Constants\CardState

  • RECEIVED, ASSESSMENT, IN_PROGRESS, etc.

  • See app/Constants/ for all 18 classes

Common Pitfalls

❌ WRONG: Using NovaBadgeType constants in Badge fields

Badge::make('Status') ->map(fn($value) => NovaBadgeType::SUCCESS); // ❌ Don't do this

✅ CORRECT: Use hardcoded strings

Badge::make('Status', function () { return $this->state; }) ->map([ 'active' => 'success', // ✅ Hardcoded strings 'inactive' => 'danger', ]);

❌ WRONG: Manual options array for Select

Select::make('Type') ->options([ 'fixed' => 'Fixed Amount', 'percentage' => 'Percentage', ]);

✅ CORRECT: Use constant options() method

Select::make('Type') ->options(PromoCodeType::options()); // ✅ Centralized

Documentation Links

  • Nova Admin Guide: docs/development/NOVA-ADMIN-GUIDE.md

  • Nova Search Guide: docs/development/NOVA-SEARCH-GUIDE.md

  • Constants Pattern: CLAUDE.md "Constants Pattern & Nova Best Practices"

  • Laravel Nova Docs: https://nova.laravel.com/docs/5.0

Source Transparency

This detail page is rendered from real SKILL.md content. Trust labels are metadata-based hints, not a safety guarantee.

Related Skills

Related by shared tags or category signals.

General

laravel package specialist

No summary provided by upstream source.

Repository SourceNeeds Review
Automation

deployment workflow

No summary provided by upstream source.

Repository SourceNeeds Review
General

ai-image-generator

AI 图片与视频异步生成技能,调用 AI Artist API 根据文本提示词生成图片或视频,自动轮询直到任务完成。 ⚠️ 使用前必须设置环境变量 AI_ARTIST_TOKEN 为你自己的 API Key! 获取 API Key:访问 https://staging.kocgo.vip/index 注册登录后创建。 支持图片模型:SEEDREAM5_0(默认高质量图片)、NANO_BANANA_2(轻量快速)。 支持视频模型:SEEDANCE_1_5_PRO(文生视频,支持音频)、SORA2(文生视频或首尾帧图生视频,支持 firstImageUrl/lastImageUrl)。 触发场景: - 用户要求生成图片,如"生成一匹狼"、"画一只猫"、"风景画"、"帮我画"等。 - 用户要求生成视频,如"生成视频"、"用 SORA2 生成"、"文生视频"、"图生视频"、"生成一段...的视频"等。 - 用户指定模型:SEEDREAM5_0、NANO_BANANA_2、SEEDANCE_1_5_PRO、SORA2。

Archived SourceRecently Updated
General

淘宝投放数据分析

# 投放数据分析技能

Archived SourceRecently Updated