has('email') && is_string($this->input('email'))) { $this->merge([ 'email' => Str::lower((string) $this->input('email')), ]); } } /** * Get the validation rules that apply to the request. * * @return array> */ public function rules(): array { return [ 'name' => [ 'string', 'max:255', ], 'email' => [ 'email', 'max:255', UniqueEloquent::make(User::class, 'email')->ignore($this->user->id)->query(function (Builder $query) { /** @var Builder $query */ return $query->where('is_placeholder', '=', false); }), ], 'photo' => [ 'nullable', new Base64ImageRule, ], 'timezone' => [ 'timezone:all', ], 'week_start' => [ Rule::enum(Weekday::class), ], ]; } public function getName(): ?string { return $this->has('name') ? (string) $this->input('name') : null; } public function getEmail(): ?string { return $this->has('email') ? Str::lower((string) $this->input('email')) : null; } public function getTimezone(): ?string { return $this->has('timezone') ? (string) $this->input('timezone') : null; } public function getWeekStart(): ?Weekday { return $this->has('week_start') ? Weekday::from($this->input('week_start')) : null; } public function getPhoto(): ?string { return $this->has('photo') ? (string) $this->input('photo') : null; } }