123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778 |
- <?php
- namespace App\Http\Requests\System;
- use App\Http\Models\Role;
- use App\Http\Requests\Request;
- use Illuminate\Database\Query\Builder;
- use Illuminate\Validation\Rule;
- class StoreUserRequest extends Request
- {
- /**
- * Determine if the user is authorized to make this request.
- *
- * @return bool
- */
- public function authorize()
- {
- return true;
- }
- /**
- * Get the validation rules that apply to the request.
- *
- * @return array
- */
- public function rules()
- {
- $addition = [];
- // if ($this->input('role_id') == Role::TYPE_CUSTOMER) {
- $addition['site_ids'] = 'nullable|array';
- // }
- return [
- 'nickname' => 'required',
- 'username' => [
- 'required',
- 'min:3',
- 'max:15',
- Rule::unique('users')->where(function (Builder $query) {
- return $query->where('deleted_at', null);
- })
- ],
- 'password' => 'min:5|max:15',
- 'phone' => [
- 'nullable',
- Rule::unique('users')->where(function (Builder $query) {
- return $query->where('deleted_at', null);
- })
- ],
- 'entry_time' => 'nullable',
- 'telephone' => 'nullable',
- 'email' => 'nullable',
- 'qq' => 'nullable',
- 'role_id' => 'required|numeric',
- 'status' => 'boolean',
- ] + $addition;
- }
- public function attributes()
- {
- return [
- 'nickname' => '昵称',
- 'username' => '用户名',
- 'password' => '密码',
- 'email' => '邮箱',
- 'qq' => 'qq号',
- 'role_id' => '角色',
- 'status' => '状态',
- 'sort' => '排序',
- 'site_id' => '站点',
- 'phone' => '手机号',
- 'telephone' => '座机',
- ];
- }
- }
|