スキル一覧に戻る
hieupvXmasEve

create-request

by hieupvXmasEve

0🍴 0📅 2026年1月6日
GitHubで見るManusで実行

SKILL.md


name: create-request description: Generates a Laravel FormRequest class for validation. Use when creating or updating data (e.g., "Add validation for student registration"). allowed-tools: Write, Read

Create Form Request

This skill generates a FormRequest class, which is the mandatory location for all validation logic in this project.

Instructions

  1. Identify Parameters:

    • Module: (e.g., Identity, Academic).
    • Context: What action is being validated? (e.g., RegisterStudent, UpdateProfile).
    • Path: app/Modules/{Module}/Http/Requests/{Module}/{ClassName}.php.
  2. Generate Code:

    • Namespace: App\Modules\{Module}\Http\Requests\{Module}
    • Method authorize(): Return true (authorization is handled by Policies/Middleware, not here, unless simple ownership check).
    • Method rules(): Return array of validation rules.
    • Strict Typing: Add string, int, array type hints to the returned rules.
  3. Naming Convention:

    • Do not prefix with Actor (e.g., StudentLoginRequest ❌).
    • Use Domain Context (e.g., LoginRequest ✅ inside Identity module).

Template

<?php

namespace App\Modules\Identity\Http\Requests\Identity;

use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Validation\Rule;

class RegisterStudentRequest extends FormRequest
{
    /**
     * Determine if the user is authorized to make this request.
     */
    public function authorize(): bool
    {
        return true; // Auth handled by Middleware/Policy
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array|string>
     */
    public function rules(): array
    {
        return [
            'first_name' => ['required', 'string', 'max:255'],
            'last_name' => ['required', 'string', 'max:255'],
            'email' => [
                'required',
                'string',
                'email',
                'max:255',
                Rule::unique('users', 'email'),
            ],
            'campus_id' => ['required', 'integer', 'exists:campuses,id'],
            'password' => ['required', 'confirmed', 'min:8'],
        ];
    }
}

Best Practices

  • Complex Rules: Use Rule:: builder (e.g., Rule::unique(), Rule::in()).
  • Custom Messages: Implement messages() only if standard messages are insufficient.
  • Attributes: Implement attributes() to provide friendly names for fields.

スコア

総合スコア

50/100

リポジトリの品質指標に基づく評価

SKILL.md

SKILL.mdファイルが含まれている

+20
LICENSE

ライセンスが設定されている

0/10
説明文

100文字以上の説明がある

0/10
人気

GitHub Stars 100以上

0/15
最近の活動

3ヶ月以内に更新がある

0/10
フォーク

10回以上フォークされている

0/5
Issue管理

オープンIssueが50未満

+5
言語

プログラミング言語が設定されている

+5
タグ

1つ以上のタグが設定されている

0/5

レビュー

💬

レビュー機能は近日公開予定です