-
-
Notifications
You must be signed in to change notification settings - Fork 658
Expand file tree
/
Copy pathUpsertCheckInListRequest.php
More file actions
43 lines (37 loc) · 1.5 KB
/
Copy pathUpsertCheckInListRequest.php
File metadata and controls
43 lines (37 loc) · 1.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
<?php
namespace HiEvents\Http\Request\CheckInList;
use HiEvents\Http\Request\BaseRequest;
use HiEvents\Validators\Rules\RulesHelper;
class UpsertCheckInListRequest extends BaseRequest
{
public function rules(): array
{
return [
'name' => RulesHelper::REQUIRED_STRING,
'description' => ['nullable', 'string', 'max:2000'],
'expires_at' => ['nullable', 'date'],
'activates_at' => ['nullable', 'date'],
'product_ids' => ['required', 'array', 'min:1'],
'public_show_attendee_notes' => ['nullable', 'boolean'],
'public_show_question_answers' => ['nullable', 'boolean'],
'public_show_order_details' => ['nullable', 'boolean'],
];
}
public function withValidator($validator): void
{
$validator->sometimes('expires_at', 'after:activates_at', function ($input) {
return $input->activates_at !== null && $input->expires_at !== null;
});
$validator->sometimes('activates_at', 'before:expires_at', function ($input) {
return $input->activates_at !== null && $input->expires_at !== null;
});
}
public function messages(): array
{
return [
'product_ids.required' => __('Please select at least one product.'),
'expires_at.after' => __('The expiration date must be after the activation date.'),
'activates_at.before' => __('The activation date must be before the expiration date.'),
];
}
}