| Conditions | 2 |
| Paths | 1 |
| Total Lines | 19 |
| Code Lines | 14 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 10 |
| CRAP Score | 2.003 |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 17 | 1 | public function rules() |
|
| 18 | { |
||
| 19 | return [ |
||
| 20 | 1 | 'branch_id' => 'required|exists:' . Branch::class . ',id', |
|
| 21 | 'username' => 'required|string|max:255|unique:' . User::class, |
||
| 22 | 1 | 'fullname' => 'required|string|max:255', |
|
| 23 | 'gender' => 'sometimes|nullable|enum:' . Gender::class, |
||
| 24 | 'email' => 'required|string|email|max:255|unique:' . User::class, |
||
| 25 | 1 | 'phone_country' => 'sometimes|in:ID', |
|
| 26 | 1 | 'phone' => ['required', 'string', 'phone:ID', function ($attribute, $phone, $fail) { |
|
| 27 | 1 | $user = User::where($attribute, PhoneNumber::make($phone, request()->input('phone_country', env('PHONE_COUNTRY', 'ID')))->formatE164())->count(); |
|
| 28 | |||
| 29 | 1 | if ($user > 0) { |
|
| 30 | $fail(trans('validation.unique', ['attribute' => static::getAttributes()[$attribute]])); |
||
| 31 | } |
||
| 32 | 1 | }], |
|
| 33 | 1 | 'password' => ['required', 'confirmed', Rules\Password::defaults()], |
|
| 34 | 'role' => 'required|exists:' . Role::class . ',name', |
||
| 35 | 1 | 'is_active' => 'required|boolean', |
|
| 36 | ]; |
||
| 39 |