Example #1
0
 /**
  * Get the pivot attributes from a model.
  *
  * @param  \Nova\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;
 }
Example #2
0
 /**
  * Get the pivot attributes from a model.
  *
  * @param  \Nova\Database\ORM\Model  $model
  * @return array
  */
 protected function cleanPivotAttributes(Model $model)
 {
     $values = array();
     foreach ($model->getAttributes() as $key => $value) {
         // To get the pivots attributes we will just take any of the attributes which
         // begin with "pivot_" and add those to this arrays, as well as unsetting
         // them from the parent's models since they exist in a different table.
         if (strpos($key, 'pivot_') === 0) {
             $values[substr($key, 6)] = $value;
             unset($model->{$key});
         }
     }
     return $values;
 }