| 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 |
/** |
| 19 |
* todo - consult with heera bhai how to proceed with this composit unique validation |
| 20 |
* |
| 21 |
*/ |
| 22 |
return [ |
| 23 |
'title' => 'required|sanitizeText|maxLength:50|unique:' . $tbl . ',title,'.$termId.',id', |
| 24 |
'slug' => 'required|sanitizeText|maxLength:50|unique:' . $tbl . ',slug,'.$termId.',id', |
| 25 |
'description' => 'nullable|sanitizeTextArea', |
| 26 |
'serial' => 'nullable|numeric' |
| 27 |
]; |
| 28 |
} |
| 29 |
|
| 30 |
|
| 31 |
/** |
| 32 |
* @return array |
| 33 |
*/ |
| 34 |
public function messages() |
| 35 |
{ |
| 36 |
return [ |
| 37 |
'title.required' => esc_html__('Title is required', 'fluent-cart'), |
| 38 |
'slug.required' => esc_html__('Slug is required', 'fluent-cart'), |
| 39 |
|
| 40 |
]; |
| 41 |
} |
| 42 |
|
| 43 |
|
| 44 |
/** |
| 45 |
* @return array |
| 46 |
*/ |
| 47 |
public function sanitize() |
| 48 |
{ |
| 49 |
return [ |
| 50 |
'serial' => 'sanitize_text_field', |
| 51 |
'description' => 'sanitize_text_field', |
| 52 |
'slug' => 'sanitize_text_field' |
| 53 |
]; |
| 54 |
} |
| 55 |
} |
| 56 |
|