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