Skip to content

Commit 31ac709

Browse files
authored
Update AllowedMimeTypes.php
1 parent 0b4829a commit 31ac709

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

Diff for: src/Media/AllowedMimeTypes.php

+16
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,22 @@ public static function getValidationRule(string $type, bool $as_array = false, ?
134134
return $as_array ? $rules : implode('|', $rules);
135135
}
136136

137+
/**
138+
* Get the validation rule for the given type of attachment
139+
*
140+
* @param string|null $type
141+
* @return array
142+
*/
143+
public static function getAttachmentValidationRule(string $type = null): array
144+
{
145+
$rules = [
146+
'nullable',
147+
Rule::exists('media', 'id')->whereIn('mime_type', AllowedMimeTypes::getAllowedMimeTypes($type)),
148+
];
149+
150+
return $rules;
151+
}
152+
137153
/**
138154
* Get the type from the mime type
139155
* @param string $mime_type

0 commit comments

Comments
 (0)