rafflesargentina/l5-action-based-form-request

Action Based FormRequest for Laravel 5

v1.7.0 2018-12-15 12:23 UTC

This package is not auto-updated.

Last update: 2024-10-27 05:52:04 UTC


README

Latest Version on Packagist Software License Build Status Total Downloads

Action Based FormRequest for Laravel 5

Install

Via Composer

$ composer require rafflesargentina/l5-action-based-form-request

Usage

Create a class that extends ActionBasedFormRequest. Then define methods that match the name of each action with request data you want to validate, returning an array with rules.

Example:

<?php

namespace App\Http\Requests;

use RafflesArgentina\ActionBasedFormRequest\ActionBasedFormRequest;

class ArticleRequest extends ActionBasedFormRequest
{
    public static function index()
    {
        return [
            'show' => 'numeric|min:1|max:400',
            'order' => 'in:asc,desc',
        ];
    }

    public static function store()
    {
        return [
            'title' => 'required|max:100',
        ];
    }

    public static function update()
    {
        return static::store();
    } 
}

And that's it :)

Testing

$ composer test

Contributing

Please see CONTRIBUTING and CONDUCT for details.

Security

If you discover any security related issues, please email mario@raffles.com.ar instead of using the issue tracker.

Credits

License

The MIT License (MIT). Please see License File for more information.