Update HasPicture
This commit is contained in:
parent
13d998ac9c
commit
f06e87daf5
1 changed files with 8 additions and 2 deletions
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue