PluginProbe
FluentCart A New Era of eCommerce – Faster, Lighter, and Simpler / 1.6.4
FluentCart A New Era of eCommerce – Faster, Lighter, and Simpler v1.6.4
1.6.4 1.6.3 1.6.2 1.6.1 1.6.0 1.5.4 1.5.5 1.5.3 1.5.2 1.5.1 1.5.0 1.4.2 1.4.1 1.4.0 1.3.28 1.3.27 1.3.26 1.3.25 1.3.23 1.3.22 1.3.21 1.3.20 1.3.19 trunk 1.2.0 All 47 releases
fluent-cart / app / Http / Requests / CartRequest.php

CartRequest.php in FluentCart A New Era of eCommerce – Faster, Lighter, and Simpler 1.6.4, at app/Http/Requests/CartRequest.php

62 lines 1.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace FluentCart\App\Http\Requests;
4
5 use FluentCart\Framework\Foundation\RequestGuard;
6
7 class CartRequest extends RequestGuard
8 {
9 /**
10 * @return array
11 */
12 public function rules()
13 {
14 return [
15 'customer_id' => 'integer',
16 'user_id' => 'integer',
17 'order_id' => 'integer',
18 'cart_hash' => 'sanitizeText',
19 'checkout_data' => 'sanitizeTextArea|maxLength:255',
20 'cart_data' => 'sanitizeTextArea',
21 'first_name' => 'sanitizeText|maxLength:255',
22 'last_name' => 'sanitizeText|maxLength:255',
23 'email' => 'sanitizeText|maxLength:255',
24 'stage' => 'sanitizeText|maxLength:30',
25 'cart_group' => 'sanitizeText|maxLength:30',
26 ];
27 }
28
29 /**
30 *
31 * @return array
32 */
33 public function messages()
34 {
35 return [
36 'customer_id' => esc_html__('Customer Id must be a number.', 'fluent-cart'),
37 'user_id' => esc_html__('User Id must be a number.', 'fluent-cart'),
38 ];
39 }
40
41
42 /**
43 *
44 * @return array
45 */
46 public function sanitize()
47 {
48 return [
49 'first_name' => 'sanitize_text_field',
50 'last_name' => 'sanitize_text_field',
51 'email' => function ($value) {
52 if(empty($value)) {
53 return '';
54 }
55
56 return sanitize_email($value);
57 },
58 ];
59 }
60 }
61
62