Skip to content

Commit

Permalink
Update AllowedMimeTypes.php
Browse files Browse the repository at this point in the history
  • Loading branch information
Lithalroden committed May 13, 2024
1 parent 0b4829a commit 31ac709
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/Media/AllowedMimeTypes.php
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,22 @@ public static function getValidationRule(string $type, bool $as_array = false, ?
return $as_array ? $rules : implode('|', $rules);
}

/**
* Get the validation rule for the given type of attachment
*
* @param string|null $type
* @return array
*/
public static function getAttachmentValidationRule(string $type = null): array
{
$rules = [
'nullable',
Rule::exists('media', 'id')->whereIn('mime_type', AllowedMimeTypes::getAllowedMimeTypes($type)),
];

return $rules;
}

/**
* Get the type from the mime type
* @param string $mime_type
Expand Down

0 comments on commit 31ac709

Please sign in to comment.