PHP code example of manzadey / request-rules-fill

1. Go to this page and download the library: Download manzadey/request-rules-fill library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

manzadey / request-rules-fill example snippets


use Manzadey\RequestRulesFill\RequestRulesFill;

$rules = new RequestRulesFill;

$rules->fields('name', 'description')->rule('string', '

$rules->replaceRule('slug', 'unique:articles', Rule::unique('articles')->ignore($this->route('article')->id));

$rules->addRuleToField('slug', 'string', 'min:2');

$rules->get();

namespace App\Http\Requests\Admin\Article;

use Manzadey\RequestRulesFill\RequestRulesFill;
use Illuminate\Foundation\Http\FormRequest;

class ArticleStoreRequest extends FormRequest
{
    public function rules() : array
    {
        return $this->makeRules()->get();
    }

    public function makeRules() : RequestRulesFill
    {
        $rules = new RequestRulesFill();
        $rules->fields('show', 'top')->rule('nullable', 'boolean');
        $rules->fields('name')->rule('

namespace App\Http\Requests\Admin\Article;

use Illuminate\Validation\Rule;

class ArticleUpdateRequest extends ArticleStoreRequest
{
    public function rules() : array
    {
        return $this->makeRules()->get();
    }

    public function makeRules() : RequestRulesFill
        {
            return parent::makeRules()->replaceRule('slug', 'unique:articles', Rule::unique('articles')->ignore($this->route('article')->id));
        }
}