/**
  * Goes through all related columns and sets the proper values for this row
  *
  * @param \Illuminate\Database\Eloquent\Model	$item
  * @param array									$outputRow
  *
  * @return void
  */
 public function parseOnTableColumns($item, array &$outputRow)
 {
     $columns = $this->columnFactory->getColumns();
     $includedColumns = $this->columnFactory->getIncludedColumns($this->fieldFactory->getEditFields());
     $relatedColumns = $this->columnFactory->getRelatedColumns();
     //loop over both the included and related columns
     foreach (array_merge($includedColumns, $relatedColumns) as $field => $col) {
         $attributeValue = $item->getAttribute($field);
         //if this column is in our objects array, render the output with the given value
         if (isset($columns[$field])) {
             $outputRow[$field] = array('raw' => $attributeValue, 'rendered' => $columns[$field]->renderOutput($attributeValue));
         } else {
             $outputRow[$field] = array('raw' => $attributeValue, 'rendered' => $attributeValue);
         }
     }
 }
Esempio n. 2
0
 /**
  * Updates a model with the latest permissions, links, and fields
  *
  * @param \Illuminate\Database\Eloquent\Model		$model
  * @param \Frozennode\Administrator\Fields\Factory	$fieldFactory
  * @param \Frozennode\Administrator\Actions\Factory	$actionFactory
  *
  * @return \Illuminate\Database\Eloquent\Model
  */
 public function updateModel($model, FieldFactory $fieldFactory, ActionFactory $actionFactory)
 {
     //set the data model to the active model
     $this->setDataModel($model->find($model->getKey()));
     //include the item link if one was supplied
     if ($link = $this->getModelLink()) {
         $model->setAttribute('admin_item_link', $link);
     }
     //set up the model with the edit fields new data
     $model->setAttribute('administrator_edit_fields', $fieldFactory->getEditFieldsArrays(true));
     //set up the new actions data
     $model->setAttribute('administrator_actions', $actionFactory->getActionsOptions(true));
     $model->setAttribute('administrator_action_permissions', $actionFactory->getActionPermissions(true));
     return $model;
 }