Changeset View
Changeset View
Standalone View
Standalone View
src/app/Rules/GroupName.php
Show First 20 Lines • Show All 42 Lines • ▼ Show 20 Line(s) | |||||
if (strlen($name) > 191) { | if (strlen($name) > 191) { | ||||
$this->message = \trans('validation.max.string', ['max' => 191]); | $this->message = \trans('validation.max.string', ['max' => 191]); | ||||
return false; | return false; | ||||
} | } | ||||
// Check if the name is unique in the domain | // Check if the name is unique in the domain | ||||
// FIXME: Maybe just using the whole groups table would be faster than groups()? | // FIXME: Maybe just using the whole groups table would be faster than groups()? | ||||
$exists = $this->owner->groups() | $exists = $this->owner->groups() | ||||
->where('groups.name', $name) | ->where('name', $name) | ||||
->where('groups.email', 'like', '%@' . $this->domain) | ->where('email', 'like', '%@' . $this->domain) | ||||
->exists(); | ->exists(); | ||||
if ($exists) { | if ($exists) { | ||||
$this->message = \trans('validation.nameexists'); | $this->message = \trans('validation.nameexists'); | ||||
return false; | return false; | ||||
} | } | ||||
return true; | return true; | ||||
Show All 12 Lines |