Allow users to write multiple items at once
This commit is contained in:
14
src/Meta.php
14
src/Meta.php
@@ -52,14 +52,22 @@ class Meta extends Model implements FoundationModel, MetaContract
|
||||
/**
|
||||
* Adds the key-value pair into the serialized data set.
|
||||
*
|
||||
* @param string|int $key
|
||||
* @param string|int|array $keyOrArray
|
||||
* @param string|int|float|array|bool|null $value
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function write( $key, $value ){
|
||||
public function write( $keyOrArray, $value = null ){
|
||||
$meta = unserialize( $this->meta );
|
||||
$meta[ $key ] = $value;
|
||||
|
||||
if( is_array( $keyOrArray ) ){
|
||||
foreach( $keyOrArray as $key => $val ){
|
||||
$meta[ $key ] = $val;
|
||||
}
|
||||
} else {
|
||||
$meta[ $keyOrArray ] = $value;
|
||||
}
|
||||
|
||||
$meta = serialize( $meta );
|
||||
$this->meta = $meta;
|
||||
$this->save();
|
||||
|
||||
Reference in New Issue
Block a user