PHP code example of tarkhov / eloquent-validation

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

    

tarkhov / eloquent-validation example snippets



namespace App;

use Illuminate\Database\Eloquent\Model;
use EloquentValidation\Database\Eloquent\ModelRules;

class Page extends Model implements ModelRules
{
    protected $fillable = [
        'is_active',
        'slug',
        'name',
        'description',
        'image',
        'title',
        'meta_description',
        'meta_keywords',
    ];

    public static function rules()
    {
        return [
            'id'               => '|string|max:255',
        ];
    }
}


namespace App\Http\Requests;

use EloquentValidation\Foundation\Http\CreateFormRequest;
use App\Page;

class CreatePage extends CreateFormRequest
{
    protected $model = 'Page';
}