public function Groups::save in SimpleAds 8
File
- src/
Groups.php, line 122
Class
- Groups
- Groups utility class.
Namespace
Drupal\simpleadsCode
public function save() {
$fields = [
'uid' => $this->user
->id(),
'name' => $this
->getGroupName(),
'description' => $this
->getDescription(),
'options' => $this
->getOptions(),
'created_at' => $this
->getCreatedAt(),
'changed_at' => $this
->getChangedAt(),
];
if ($id = $this
->getId()) {
$query = db_update('simpleads_groups')
->fields($fields)
->condition('id', $id);
drupal_set_message($this
->t('Group successfully updated.'));
}
else {
$query = db_insert('simpleads_groups')
->fields($fields);
drupal_set_message($this
->t('New Group successfully created.'));
}
$query
->execute();
}