refs #436 fixed update unique

This commit is contained in:
cuneytsenturk 2018-08-02 15:23:38 +03:00
parent 987033352f
commit d0dbf23d5a
2 changed files with 16 additions and 2 deletions

View File

@ -23,8 +23,15 @@ class Permission extends FormRequest
*/
public function rules()
{
// Check if store or update
if ($this->getMethod() == 'PATCH') {
$id = $this->role->getAttribute('id');
} else {
$id = null;
}
return [
'name' => 'required|string|unique:permissions,name',
'name' => 'required|string|unique:permissions,name,' . $id,
'display_name' => 'required|string',
];
}

View File

@ -23,8 +23,15 @@ class Role extends FormRequest
*/
public function rules()
{
// Check if store or update
if ($this->getMethod() == 'PATCH') {
$id = $this->role->getAttribute('id');
} else {
$id = null;
}
return [
'name' => 'required|string|unique:roles,name',
'name' => 'required|string|unique:roles,name,' . $id,
'display_name' => 'required|string',
'permissions' => 'required'
];