additionsl property at list
This commit is contained in:
@ -78,7 +78,7 @@ class EntityRelation
|
||||
$entity_relations_info = Option::where("key", "entity_relations")->first();
|
||||
if ($entity_relations_info) {
|
||||
$entity_relations = json_decode($entity_relations_info->value, true);
|
||||
foreach ($entity_relations as $entity => $entity_relation){
|
||||
foreach ($entity_relations as $entity => $entity_relation) {
|
||||
if (in_array($property, $entity_relation)) {
|
||||
$index = array_search($property, $entity_relation);
|
||||
unset($entity_relations[$entity][$index]);
|
||||
@ -113,7 +113,7 @@ class EntityRelation
|
||||
{
|
||||
$entityRelations = $this->getEntitiesRelations();
|
||||
if ($entityRelations) {
|
||||
if (isset($entityRelations[$slug])){
|
||||
if (isset($entityRelations[$slug])) {
|
||||
return $entityRelations[$slug];
|
||||
}
|
||||
}
|
||||
@ -161,8 +161,8 @@ class EntityRelation
|
||||
public function renderEntityAdditionalPropertyFormBySlug(string $entity, Model $model = null): void
|
||||
{
|
||||
$relations = $this->getEntityRelationsBySlug($entity);
|
||||
if ($relations){
|
||||
foreach ($relations as $relation){
|
||||
if ($relations) {
|
||||
foreach ($relations as $relation) {
|
||||
$this->renderFormInputsBySlug($entity, $relation, $model);
|
||||
}
|
||||
}
|
||||
@ -179,8 +179,8 @@ class EntityRelation
|
||||
public function saveEntityRelation(string $entity, Model $model, Request $request): void
|
||||
{
|
||||
$relations = $this->getEntityRelationsBySlug($entity);
|
||||
if ($relations){
|
||||
foreach ($relations as $relation){
|
||||
if ($relations) {
|
||||
foreach ($relations as $relation) {
|
||||
$this->saveEntityRelationBySlug($relation, $entity, $model, $request);
|
||||
}
|
||||
}
|
||||
@ -189,9 +189,9 @@ class EntityRelation
|
||||
public function getEntityAdditionalProperty(string $entity, Model $model): array
|
||||
{
|
||||
$relations = $this->getEntityRelationsBySlug($entity);
|
||||
if ($relations){
|
||||
if ($relations) {
|
||||
$relationsArr = [];
|
||||
foreach ($relations as $relation){
|
||||
foreach ($relations as $relation) {
|
||||
$moduleClass = $this->getAdditionalPropertyClassBySlug($relation);
|
||||
if ($moduleClass and method_exists($moduleClass, "getItems")) {
|
||||
$relationsArr[$relation] = $moduleClass->getItems($entity, $model);
|
||||
@ -204,6 +204,16 @@ class EntityRelation
|
||||
return [];
|
||||
}
|
||||
|
||||
public function getAdditionalPropertyByEntityId(string $entity, string $entity_id, string $additionalPropertySlug): string
|
||||
{
|
||||
$moduleClass = $this->getAdditionalPropertyClassBySlug($additionalPropertySlug);
|
||||
if ($moduleClass and method_exists($moduleClass, "getItem")) {
|
||||
return $moduleClass->getItem($entity, $entity_id);
|
||||
}
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
public function deleteEntityRelationBySlug(string $slug, string $entity, Model $model): void
|
||||
{
|
||||
$moduleClass = $this->getAdditionalPropertyClassBySlug($slug);
|
||||
@ -215,8 +225,8 @@ class EntityRelation
|
||||
public function deleteEntityRelation(string $entity, Model $model): void
|
||||
{
|
||||
$relations = $this->getEntityRelationsBySlug($entity);
|
||||
if ($relations){
|
||||
foreach ($relations as $relation){
|
||||
if ($relations) {
|
||||
foreach ($relations as $relation) {
|
||||
$this->deleteEntityRelationBySlug($relation, $entity, $model);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user