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 / ProductDownloadable / ProductDownloadableFileRequest.php

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

78 lines 2.4 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\ProductDownloadable;
4
5 use FluentCart\Framework\Foundation\RequestGuard;
6
7 class ProductDownloadableFileRequest extends RequestGuard
8 {
9
10 /**
11 * @return array
12 */
13 public function rules()
14 {
15
16 return [
17 //'product_variation_id' => 'required|array|min:1',
18 'title' => 'required|sanitizeText|maxLength:100',
19 'type' => 'required|sanitizeText|maxLength:100',
20 'driver' => 'required|sanitizeText|maxLength:100',
21 'file_name' => 'required|sanitizeText|maxLength:100',
22 'settings.download_limit' => 'nullable|numeric',
23 'settings.download_expiry' => 'nullable|numeric',
24 ];
25 }
26
27
28 /**
29 * @return array
30 */
31 public function messages(): array
32 {
33 return [
34 'title.required' => esc_html__('Title is required.', 'fluent-cart'),
35 'type.required' => esc_html__('Type is required.', 'fluent-cart'),
36 'driver.required' => esc_html__('Driver is required.', 'fluent-cart'),
37 'file_name.required' => esc_html__('File Name is required.', 'fluent-cart'),
38 'file_path.required' => esc_html__('File Path is required.', 'fluent-cart'),
39 'file_url.required' => esc_html__('File URL is required.', 'fluent-cart'),
40 ];
41 }
42
43
44 /**
45 * @return array
46 */
47 public function sanitize()
48 {
49
50 return [
51 'id' => 'intval',
52 //'post_id' => 'intval',
53 'product_variation_id' => function ($value) {
54 if (!is_array($value)) {
55 return [];
56 }
57 return array_values(array_filter(array_map(function ($id) {
58 return sanitize_text_field($id);
59 }, $value)));
60 },
61 //'download_identifier' => 'sanitize_text_field',
62 'title' => 'sanitize_text_field',
63 'type' => 'sanitize_text_field',
64 'driver' => 'sanitize_text_field',
65 'file_name' => 'sanitize_text_field',
66 'file_path' => 'sanitize_text_field',
67 'file_url' => 'sanitize_text_field',
68 'settings' => function ($value) {
69 return $value;
70 },
71 'serial' => 'intval',
72 //'created_at' => 'sanitize_text_field',
73 //'updated_at' => 'sanitize_text_field',
74 ];
75
76 }
77 }
78