first(); if ($entity_relations) { $entity_relations = json_decode($entity_relations->value, true); $entities = []; foreach ($entity_relations as $entity => $relation) { $entities[] = $entity; } return $entities; } return []; } public function addEntityRelation(array $data): bool { $entity_relations_info = Option::where("key", "entity_relations")->first(); if ($entity_relations_info) { $entity_relations = json_decode($entity_relations_info->value, true); foreach ($data as $entity => $relation) { $entity_relations[$entity] = $relation; } $entity_relations_info->value = json_encode($entity_relations, JSON_UNESCAPED_UNICODE); $entity_relations_info->save(); return true; } return false; } }