Skip to content

Commit e9cfbd8

Browse files
committed
feat: Add param removeNull to method: Metable::setMetaAttribute
1 parent 08fd108 commit e9cfbd8

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@ All notable changes to this project will be documented in this file.
44

55
The format is based on [Keep a Changelog][keepachangelog] and this project adheres to [Semantic Versioning][semver].
66

7+
## v4.4.2
8+
9+
### Changed
10+
11+
- Add param `removeNull` to method: `Metable::setMetaAttribute`
12+
713
## v4.4.0
814

915
### Added

src/Traits/Metable.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,15 @@ public function metaAttribute(string $key, mixed $default = null)
4343
/**
4444
* @param string $key
4545
* @param mixed $value
46+
* @param bool $removeNull
4647
*
4748
* @return $this
4849
*/
49-
public function setMetaAttribute(string $key, mixed $value): static
50+
public function setMetaAttribute(string $key, mixed $value, bool $removeNull = false): static
5051
{
51-
Arr::set($this->meta, $key, $value);
52+
if ($value !== null || !$removeNull) {
53+
Arr::set($this->meta, $key, $value);
54+
}
5255

5356
return $this;
5457
}

0 commit comments

Comments
 (0)