| 1 |
<?php |
| 2 |
|
| 3 |
namespace FluentCart\App\Http\Requests; |
| 4 |
|
| 5 |
use FluentCart\Framework\Foundation\RequestGuard; |
| 6 |
|
| 7 |
class AttrTermRequest extends RequestGuard |
| 8 |
{ |
| 9 |
|
| 10 |
/** |
| 11 |
* @return array |
| 12 |
*/ |
| 13 |
public function rules() |
| 14 |
{ |
| 15 |
$termId = $this->get('term_id'); |
| 16 |
$tbl = 'fct_atts_terms'; |
| 17 |
|
| 18 |
return [ |
| 19 |
'title' => 'required|sanitizeText|maxLength:50', |
| 20 |
'slug' => 'required|sanitizeText|maxLength:50|unique:' . $tbl . ',slug,'.$termId.',id', |
| 21 |
'description' => 'nullable|sanitizeTextArea', |
| 22 |
'serial' => 'nullable|numeric' |
| 23 |
]; |
| 24 |
} |
| 25 |
|
| 26 |
|
| 27 |
/** |
| 28 |
* @return array |
| 29 |
*/ |
| 30 |
public function messages() |
| 31 |
{ |
| 32 |
return [ |
| 33 |
'title.required' => esc_html__('Title is required', 'fluent-cart'), |
| 34 |
'slug.required' => esc_html__('Slug is required', 'fluent-cart'), |
| 35 |
|
| 36 |
]; |
| 37 |
} |
| 38 |
|
| 39 |
|
| 40 |
/** |
| 41 |
* @return array |
| 42 |
*/ |
| 43 |
public function sanitize() |
| 44 |
{ |
| 45 |
return [ |
| 46 |
'title' => 'sanitize_text_field', |
| 47 |
'serial' => 'sanitize_text_field', |
| 48 |
'description' => 'sanitize_text_field', |
| 49 |
'slug' => 'sanitize_text_field' |
| 50 |
]; |
| 51 |
} |
| 52 |
} |
| 53 |
|