Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
0.00% covered (danger)
0.00%
0 / 22
0.00% covered (danger)
0.00%
0 / 2
CRAP
0.00% covered (danger)
0.00%
0 / 1
UpdateUserRequest
0.00% covered (danger)
0.00%
0 / 22
0.00% covered (danger)
0.00%
0 / 2
30
0.00% covered (danger)
0.00%
0 / 1
 prepareForValidation
0.00% covered (danger)
0.00%
0 / 7
0.00% covered (danger)
0.00%
0 / 1
20
 rules
0.00% covered (danger)
0.00%
0 / 15
0.00% covered (danger)
0.00%
0 / 1
2
1<?php
2
3namespace App\Http\Requests\Bo\Users;
4
5use Illuminate\Validation\Rules\Password;
6
7class UpdateUserRequest extends StoreUserRequest
8{
9    /**
10     * Prepare the data for validation.
11     *
12     * @return void
13     */
14    protected function prepareForValidation()
15    {
16        $this->merge([
17            'published' => $this->published ? true : false,
18            'password' => $this->password ? $this->password : $this->route('user')->password,
19            'password_confirmation' => $this->password_confirmation ?
20                $this->password_confirmation :
21                $this->route('user')->password
22        ]);
23    }
24
25    /**
26     * Get the validation rules that apply to the request.
27     *
28     * @return array
29     */
30    public function rules(): array
31    {
32        return array_merge(parent::rules(), [
33            'email' => [
34                'required',
35                'email:rfc,strict,dns,spoof,filter',
36                'unique:users,email,' . $this->route('user')->id . ',id',
37            ],
38            'password' => [
39                'required', 'required_with:password_confirmation', 'confirmed', 'max:255', Password::min(8)
40                    ->letters()
41                    ->mixedCase()
42                    ->numbers()
43                    ->symbols()
44                    ->uncompromised()
45            ],
46        ]);
47    }
48}