PHP code example of it-brains / laravel-validator

1. Go to this page and download the library: Download it-brains/laravel-validator 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/ */

    

it-brains / laravel-validator example snippets


...
use Illuminate\Validation\Rule;
...

public function rules()
{
    return [
        'title' => [
            Rule::unique('containers', 'name')
                ->where('user_id', $this->user()->id)
                ->whereNull('deleted_at'),
        ],
        
        // other rules
        'type' => Rule::in(['A', 'B']),
        ...
    ];
}

...

...
use App\Container;
use ITBrains\Validation\Rule;
...

public function rules()
{
    return [
        'title' => [
            Rule::uniqueModel(Container::class, 'name')
                ->where('user_id', $this->user()->id),
                
            // other rules
            'type' => Rule::in(['A', 'B']),
            ...
        ],
    ];
}

...