/** * todo move to command * @param $account */ public function customer_logout(Entity $account) { if ($account->getEntityName() == 'customer') { $cart = app('App\\Cart'); $cart->unsetCart(); } }
public function tableHeaders(Entity $entity, array $allowed) { $labels = []; $attributes = $entity->getAttributes(); foreach ($allowed as $label => $attribute) { // use label provided if (is_string($label)) { $labels[] = $label; // use entity config label } elseif (isset($attributes[$attribute]['label'])) { $labels[] = $attributes[$attribute]['label']; // use the attribute code } else { $labels[] = $attribute; } } return $labels; }
protected function prepareRelationships(Entity $entity) { $attributes = []; $relationships = $entity->getRelationshipConfig(); foreach ($relationships as $relationship) { $table = $relationship['table']; $foreignKey = $this->underscore($relationship['entity']) . '_id'; $localKey = $this->underscore($entity->getEntityName()) . '_id'; $attribute = $this->applyAttributeDefaults(['parent' => $relationship['entity']]); if ($relationship['type'] == Relationship::HAS_PIVOT && !isset($this->pivots[$relationship['table']])) { $this->pivots[$table][$foreignKey] = $attribute; $this->pivots[$table][$localKey] = $this->applyAttributeDefaults(['parent' => $entity->getEntityName()]); } elseif ($relationship['type'] == Relationship::HAS_ONE) { $attributes[$foreignKey] = $attribute; } elseif ($relationship['type'] == Relationship::BELONGS_TO) { $attributes[$foreignKey] = $attribute; } } return $attributes; }
/** * Simply saves the given instance * * @param Entity $instance * * @return boolean Success */ public function save(Entity $instance) { return $instance->save(); }