fluent-cart
/
app
/
Http
/
Requests
/
FrontendRequests
/
CustomerRequests
/
CustomerProfileAccountDetailsRequest.php
CustomerProfileAccountDetailsRequest.php in FluentCart A New Era of eCommerce – Faster, Lighter, and Simpler 1.6.4, at app/Http/Requests/FrontendRequests/CustomerRequests/CustomerProfileAccountDetailsRequest.php
| 1 | <?php |
| 2 | |
| 3 | namespace FluentCart\App\Http\Requests\FrontendRequests\CustomerRequests; |
| 4 | |
| 5 | use FluentCart\Framework\Foundation\RequestGuard; |
| 6 | |
| 7 | class CustomerProfileAccountDetailsRequest extends RequestGuard |
| 8 | { |
| 9 | |
| 10 | /** |
| 11 | * @return array |
| 12 | */ |
| 13 | public function rules() |
| 14 | { |
| 15 | |
| 16 | return [ |
| 17 | 'first_name' => 'sanitizeText|maxLength:255', |
| 18 | 'last_name' => 'sanitizeText|maxLength:255', |
| 19 | 'email' => 'required|email', |
| 20 | 'current_password' => 'sanitizeText|nullable', |
| 21 | 'new_password' => 'sanitizeText|nullable', |
| 22 | 'confirm_new_password' => 'sanitizeText|nullable', |
| 23 | ]; |
| 24 | } |
| 25 | |
| 26 | /** |
| 27 | * @return array |
| 28 | */ |
| 29 | public function messages() |
| 30 | { |
| 31 | return [ |
| 32 | 'email.required' => esc_html__('Email field is required.', 'fluent-cart') |
| 33 | ]; |
| 34 | } |
| 35 | |
| 36 | /** |
| 37 | * @return array |
| 38 | */ |
| 39 | public function sanitize() |
| 40 | { |
| 41 | return [ |
| 42 | 'first_name' => 'sanitize_text_field', |
| 43 | 'last_name' => 'sanitize_text_field', |
| 44 | 'email' => function ($value) { |
| 45 | if(empty($value)) { |
| 46 | return ''; |
| 47 | } |
| 48 | |
| 49 | return sanitize_email($value); |
| 50 | }, |
| 51 | 'new_password' => '', |
| 52 | 'current_password' => '', |
| 53 | 'confirm_new_password' => '' |
| 54 | ]; |
| 55 | } |
| 56 | } |
| 57 |