diff --git a/app/Traits/Requests/HasPicture.php b/app/Traits/Requests/HasPicture.php index b8355ac..a7635e3 100644 --- a/app/Traits/Requests/HasPicture.php +++ b/app/Traits/Requests/HasPicture.php @@ -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); }