PHP code example of pyxeel / merge_rules

1. Go to this page and download the library: Download pyxeel/merge_rules 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/ */

    

pyxeel / merge_rules example snippets


MergeRules::merge([$rules, "prefix"], $moreRules);



namespace App;

use Illuminate\Database\Eloquent\Model;

class ModelOne extends Model
{
    public static $rules = [
        'date' => 'date|



namespace App;

use Illuminate\Database\Eloquent\Model;

class ModelTwo extends Model
{
    public static $rules = [
        'name' => 'string|



namespace App\Http\Requests;

use Illuminate\Foundation\Http\FormRequest;

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

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
        return MergeRules::merge([ModelOne::rules(), "ModelOne"], ModelTwo::rules());
    }
}


array:5 [▼
  "ModelOne" => "quired"
  "ModelOne.description" => "string|nullable"
  "name" => "string|

php artisan make:request CustomRequest