12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152 |
- <?php
- namespace App\Http\Requests\API\User;
- use App\Http\Requests\RuleHelper;
- use Illuminate\Foundation\Http\FormRequest;
- use Illuminate\Support\Facades\Auth;
- use Illuminate\Support\Facades\Hash;
- class UpdateRequest extends FormRequest
- {
- use RuleHelper;
-
- public function authorize(): bool
- {
- return true;
- }
-
- public function rules(): array
- {
- return [
- 'name' => 'required|max:100',
- 'email' => 'required|email',
- 'password' =>'nullable|min:6|regex:/^(?=.*[a-z])(?=.*[A-Z])(?=.*\d).{6,}$/',
- 'auth_password' => [
- 'required',
- function ($attribute, $value, $fail) {
- if (!Hash::check($value, Auth::user()->password)) {
- $fail("Wrong security authentication password!");
- }
- }
- ],
- 'phone'=>'nullable|regex:/^\d{8,11}$/',
- 'gender'=>'nullable|in:1,0',
- 'address'=>'nullable|max:255',
- 'company_id'=>'exists:company,id',
- 'department_id'=>'nullable|exists:department,id',
- 'role_id'=>'required|exists:roles,id',
- ];
- }
- }
|