LaravelPackages.net
Acme Inc.
Toggle sidebar
finalgamer/laravel-method-form-request

Package to help organize form request validation for Laravel

3.898
0
v1.3
About finalgamer/laravel-method-form-request

finalgamer/laravel-method-form-request is a Laravel package for package to help organize form request validation for laravel. It currently has 0 GitHub stars and 3.898 downloads on Packagist (latest version v1.3). Install it with composer require finalgamer/laravel-method-form-request. Discover more Laravel packages by finalgamer or browse all Laravel packages to compare alternatives.

Last updated

Laravel Method Form Request

This package helps you organize request validation data for Laravel form requests.

Instead of having multiple form request files for creating and updateing you can store both validation rules in the same file.

Installation

Install as a composer dependency.

composer require finalgamer/laravel-method-form-request

Usage

<?php

namespace App\Http\Requests;

use LaravelMethodFormRequest\FormRequest;

class UserRequest extends FormRequest
{
    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function createRules(): array
    {
        return [
            'name' => 'required|string',
            'email' => 'required|email',
            'password' => 'required|string',
        ];
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function updateRules(): array
    {
        return [
            'name' => 'string',
            'email' => 'email',
            'password' => 'string',
        ];
    }
    
    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function deleteRules(): array
    {
        // Also supports DELETE requests. Altough this is used very rarely.
        
        return [];
    }
}

Star History Chart