PluginProbe
FluentCart A New Era of eCommerce – Faster, Lighter, and Simpler / 1.4.2
FluentCart A New Era of eCommerce – Faster, Lighter, and Simpler v1.4.2
1.6.6 1.6.5 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 All 49 releases
fluent-cart / app / Http / Requests / AttrGroupRequest.php

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

60 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 AttrGroupRequest extends RequestGuard
8 {
9
10 /**
11 * @return string[]
12 */
13 public function rules()
14 {
15 $groupId = $this->get('group_id');
16 $tbl = 'fct_atts_groups';
17
18 return [
19 'title' => 'required|sanitizeText|maxLength:50',
20 'slug' => 'required|sanitizeText|maxLength:50|unique:' . $tbl . ',slug,' . $groupId.',id',
21 'description' => 'nullable|sanitizeTextArea',
22
23 ];
24 }
25
26 /**
27 *
28 * @return array
29 */
30 public function messages()
31 {
32 return [
33 'title' => esc_html__('Group title can not be empty.', 'fluent-cart'),
34 'slug' => esc_html__('Group slug can not be empty and must be unique.', 'fluent-cart'),
35 'description' => esc_html__('Group description should be long text.', 'fluent-cart'),
36 'settings' => esc_html__('Group settings should be long text.', 'fluent-cart'),
37 ];
38 }
39
40
41 /**
42 *
43 * @return array
44 */
45 public function sanitize()
46 {
47 return [
48 'title' => 'sanitize_text_field',
49 'description' => 'sanitize_text_field',
50 'slug' => 'sanitize_text_field',
51 'settings' => function ($value) {
52 if (!is_array($value)) {
53 return [];
54 }
55 return array_map('sanitize_text_field', $value);
56 },
57 ];
58 }
59 }
60