public function storeMeta($metaData, $metaType, $metaId, $metaModel = Meta::class)
    {
        // Validation required instead of type hinting because it could be passed as false or NULL
        if (!is_array($metaData)) {
            return;
        }

        foreach ($metaData as $key => $value) {
            $modelInstance = call_user_func(
                [$metaModel, 'firstOrNew'],
                [
                    'key'       => $key,
                    'meta_type' => $metaType,
                    'meta_id'   => $metaId,
                ]
            );

            $value = $this->removeEmptyValues($value);
            if (!empty($value)) {
                $modelInstance->setAttribute('value', $value);
                $modelInstance->save();
                continue;
            }

            // The value is empty, remove the row
            if ($modelInstance->exists) {
                $modelInstance->delete();
            }
        }
    }
public function storeMeta($metaData, $metaType, $metaId, $metaModel = Meta::class)
    {
        // Validation required instead of type hinting because it could be passed as false or NULL
        if (!is_array($metaData)) {
            return;
        }

        foreach ($metaData as $key => $value) {
            $modelInstance = call_user_func(
                [$metaModel, 'firstOrNew'],
                [
                    'key'       => $key,
                    'meta_type' => $metaType,
                    'meta_id'   => $metaId,
                ]
            );

            $value = $this->removeEmptyValues($value);
            if (!empty($value)) {
                $modelInstance->setAttribute('value', $value);
                $modelInstance->save();
                continue;
            }

            // The value is empty, remove the row
            if ($modelInstance->exists) {
                $modelInstance->delete();
            }
        }
    }
public function storeMeta ( $ metaData , $ metaType , $ metaId , $ metaModel = Meta :: class ) { // Validation required instead of type hinting because it could be passed as false or NULL if ( ! is_array ( $ metaData ) ) { return ; } foreach ( $ metaData as $ key => $ value ) { $ modelInstance = call_user_func ( [ $ metaModel , 'firstOrNew' ] , [ 'key' => $ key , 'meta_type' => $ metaType , 'meta_id' => $ metaId , ] ) ; $ value = $ this -> removeEmptyValues ( $ value ) ; if ( ! empty ( $ value ) ) { $ modelInstance -> setAttribute ( 'value' , $ value ) ; $ modelInstance -> save ( ) ; continue ; } // The value is empty, remove the row if ( $ modelInstance -> exists ) { $ modelInstance -> delete ( ) ; } } }
Stores all Meta values of a model.

@param array      $metaData
@param string     $metaType
@param string|int $metaId
@param string     $metaModel

@return void
Stores all Meta values of a model .