/** * Get the pivot attributes from a model. * * @param \Database\ORM\Model $model * @return array */ protected function cleanPivotAttributes(Model $model) { $values = array(); foreach ($model->getAttributes() as $key => $value) { if (strpos($key, 'pivot_') === 0) { $values[substr($key, 6)] = $value; unset($model->{$key}); } } return $values; }