Copy // Syntax
$model -> updateMetadataById ( string $id , array| Collection $metadata ) : bool
Copy $company -> createMetadata ( [ 'theme' => 'dark' ] ) ;
$company -> updateMetadataById ( $id , [ 'theme' => 'light' ] ) ;
// Using array
$company -> updateMetadataById ( $id , [ 'theme' => 'auto' , 'year' => 1997 ] ) ;
// The updated metadata will be:
[
'theme' => 'auto' ,
'year' => 1997 ,
];
// Using Collection
$company -> updateMetadataById ( $id , collect ( [ 'theme' => 'dark' , 'year' => 1998 ] )) ;
// The updated metadata will be:
[
'theme' => 'dark' ,
'year' => 1998 ,
];
Copy // Syntax
// @param $id string
// @param $keys array|Collection|string|int|null
// @param $value array|Collection|string|int|float|bool|null
$model -> updateKeysMetadataById ( $id , $keys , $value = null ) : bool
Copy
// +++++++++++++++++ array Keys +++++++++++++++++
$company -> updateKeysMetadataById ( $id , [ 'theme' => 'light' , 'year' => 2000 ] ) ;
// will be: ['theme' => 'light', 'year' => 2000];
$company -> updateKeysMetadataById ( $id , [ 'theme' => 'dark' ] ) ;
// will be: ['theme' => 'dark', 'year' => 2000];
// +++++++++++++++++ Collection Keys +++++++++++++++++
$company -> updateKeysMetadataById ( $id , collect ( [ 'theme' => 'auto' , 'year' => 2021 ] )) ;
// will be: ['theme' => 'auto', 'year' => 2021];
// ++++++++++ Individual Key ++++++++++
$company -> updateKeysMetadataById ( $id , 'year' , 1997 ) ;
// will be: ['theme' => 'auto', 'year' => 1997];
$company -> updateKeysMetadataById ( $id , 'year' , '' ) ;
// will be: ['theme' => 'auto', 'year' => ''];
$company -> updateKeysMetadataById ( $id , 'year' , null ) ;
// will be: ['theme' => 'auto', 'year' => null];
$company -> updateKeysMetadataById ( $id , 'theme' , [ 'light' , 'dark' ] ) ;
// will be: ['theme' => [0 => 'light', 1 => 'dark'], 'year' => null];
Copy // Syntax
// @param $id string
// @param $key string|int|null
// @param $value array|Collection|string|int|float|bool|null
$model -> updateKeyMetadataById ( $id , $key , $value = null ) : bool
Copy $company -> updateKeyMetadataById ( $id , 'year' , 1997 ) ;
$company -> updateKeyMetadataById ( $id , 'theme' , 'auto' ) ;
$company -> updateKeyMetadataById ( $id , 'year' , '' ) ;
$company -> updateKeyMetadataById ( $id , 'year' , null ) ;
$company -> updateKeyMetadataById ( $id , 'theme' , [ 'light' , 'dark' ] ) ;
$company -> updateKeyMetadataById ( $id , 'theme' , collect ( [ 'light' , 'dark' ] )) ;
$company -> updateKeyMetadataById ( $id , 'year' , 34 . 7 ) ;