Skip to content
Icon

WARNING You're browsing the documentation for an upcoming version of Laravel DataTables. The documentation and features of this release are subject to change.

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',
];
}