Skip to content

Latest commit

 

History

History
56 lines (43 loc) · 1.15 KB

editor-rules.md

File metadata and controls

56 lines (43 loc) · 1.15 KB

DataTables Editor Rules

DataTables Editor requires three (3) rules for create, edit and remove action respectively.

Create Rules

This are the rules that will be used when validating a create action.

public function createRules() {
    return [
        'email' => 'required|email|unique:users',
        'name'  => 'required',
    ];
}

Edit Rules

This are the rules that will be used when validating an edit action.

public function editRules(Model $model) {
    return [
        'email'      => 'sometimes|required|email|' . Rule::unique($model->getTable())->ignore($model->getKey()),
        'first_name' => 'sometimes|required',
    ];
}

Remove Rules

This are the rules that will be used when validating a remove action.

public function removeRules(Model $model) {
    return [];
}

Upload Rules

This are the rules that will be used when validating an upload action.

public function uploadRules() {
    return [
        'avatar' => 'required|image',
        'resume' => 'required|mimes:pdf',
    ];
}