public function rules(): array
{
return [
'stream' => [
'nullable',
Rule::prohibitedIf($this->isNotFilled('start_at')),
'array:end_at,viewer_stats,stream_profile,technician,end_of_stream_message,adhoc_protocol,adhoc_username,adhoc_password',
],
'stream.end_at' => [
'date_format:Y-m-d H:i:s',
'after:start_at',
],
'stream.viewer_stats' => [
'nullable',
'boolean',
],
'stream.stream_profile' => [
'string',
Rule::exists('stream_profiles', 'hash')
->withoutTrashed()
->where('organization_id', tenant()->getOrganization()->id),
'prohibits:stream.technician',
],
'stream.technician' => [
'string',
Rule::exists('organizations', 'hash')
->withoutTrashed()
->where('type', OrganizationTypeEnum::TECHNICIAN),
'prohibits:stream.stream_profile,stream.adhoc_profile,stream.adhoc_host,stream.adhoc_username,stream.adhoc_password',
],
'stream.end_of_stream_message' => [
'nullable',
'string',
],
'stream.adhoc_protocol' => [
'nullable',
'string',
StreamTypeEnum::rule(),
],
'stream.adhoc_host' => [
'nullable',
'string',
Rule::requiredIf(in_array($this->input('stream.adhoc_protocol'), [StreamTypeEnum::RTSP, StreamTypeEnum::RTMP_PULL])),
],
'stream.adhoc_username' => [
'nullable',
'string',
Rule::prohibitedIf(!in_array($this->input('stream.adhoc_protocol'), [StreamTypeEnum::RTSP, StreamTypeEnum::RTMP_PULL])),
],
'stream.adhoc_password' => [
'nullable',
'string',
Rule::prohibitedIf($this->isNotFilled('stream.adhoc_password')),
Rule::prohibitedIf(!in_array($this->input('stream.adhoc_protocol'), [StreamTypeEnum::RTSP, StreamTypeEnum::RTMP_PULL])),
],
];
}