| Conditions | 4 |
| Paths | 2 |
| Total Lines | 20 |
| Code Lines | 14 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 26 | public function rules() |
||
| 27 | { |
||
| 28 | $status_in = [ |
||
| 29 | AdminUser::STATUS_DISABLE, |
||
| 30 | AdminUser::STATUS_ENABLE, |
||
| 31 | ]; |
||
| 32 | |||
| 33 | $passwordRule = ''; |
||
| 34 | if ($this->method() == 'POST' || |
||
| 35 | ($this->method() == 'PUT' && request()->post('password') !== '')) { |
||
| 36 | $passwordRule = [ |
||
| 37 | 'required', |
||
| 38 | 'regex:/^(?![0-9]+$)(?![a-zA-Z]+$)[\w\x21-\x7e]{6,18}$/' |
||
| 39 | ]; |
||
| 40 | } |
||
| 41 | return [ |
||
| 42 | 'name' => 'required|max:50', |
||
| 43 | 'password' => $passwordRule, |
||
| 44 | 'status' => [ |
||
| 45 | Rule::in($status_in), |
||
| 46 | ], |
||
| 64 |