【Laravel】artisanのmake:requestコマンドを解説

Laravel

Laravel 10.xのartisanの「make:request」コマンドを解説します。

Description

新しいフォームリクエストクラスの作成

Usage

php artisan make:request [-f|--force] [--] <name>

Arguments

引数必須設営
name必須フォームリクエストクラス名

Options

オプション省略形必須説明
forcef-リクエストが既に存在する場合でも、クラスを作成

Examples

no options

php artisan make:request FooRequest
   INFO  Request [app/Http/Requests/FooRequest.php] created successfully.  
<?php

namespace App\Http\Requests;

use Illuminate\Foundation\Http\FormRequest;

class FooRequest extends FormRequest
{
    /**
     * Determine if the user is authorized to make this request.
     */
    public function authorize(): bool
    {
        return false;
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array<string, \Illuminate\Contracts\Validation\Rule|array|string>
     */
    public function rules(): array
    {
        return [
            //
        ];
    }
}

Follow me!

コメント

PAGE TOP
タイトルとURLをコピーしました