Update HasPicture

This commit is contained in:
Jérémy Munsch 2023-12-21 14:49:01 +01:00
parent 13d998ac9c
commit f06e87daf5
No known key found for this signature in database
GPG key ID: 18361AF3BFEC0FEC

View file

@ -48,6 +48,8 @@ trait HasPicture
* @param boolean $nullable
* @param integer|null $size
* @param string|null $requiredWith
* @param string|null $requiredWithout
* @param string|null $requiredIf
* @return array
*/
public function pictureRules(
@ -59,6 +61,8 @@ trait HasPicture
bool $nullable = false,
?int $size = null,
?string $requiredWith = null,
?string $requiredWithout = null,
?string $requiredIf = null,
): array {
$dimensions = (object)[
'minWith' => $minWith ?? $this->minWith,
@ -69,8 +73,10 @@ trait HasPicture
return [
$name => [
!$nullable ? 'required' : 'nullable',
(strlen($requiredWith)) ? 'required_with:' . $requiredWith : '',
($size) ? 'max:' . $size : '',
(!empty($requiredWith)) ? "required_with:{$requiredWith}" : '',
(!empty($requiredWithout)) ? "required_without:{$requiredWithout}" : '',
(!empty($requiredIf)) ? "required_if:{$requiredIf}" : '',
($size) ? "max:{$size}" : '',
function (string $attribute, $value, callable $fail) use ($dimensions) {
return ToolboxHelper::validatePicture($attribute, $value, $fail, $dimensions);
}