diff --git a/README.md b/README.md
index c3c9c45..313a2f4 100644
--- a/README.md
+++ b/README.md
@@ -71,6 +71,24 @@ To generate a list of users that has logged in the last 30 days:
{% endif %}
```
+### Report Target Example
+
+Report targets makes it possible to send the result of a report to target channels.
+
+For now, email is supported, with Slack and more coming soon.
+
+Example email body:
+```twig
+Report generated for {{ target.name }}
+This report includes:
+
+{% for report in reports %}
+- {{ report.name }}
+{% endfor %}
+```
+
+Note that you have access to both the reports attached to the target and the target itself.
+
## Reports Roadmap
Some things to do, and ideas for potential features:
diff --git a/src/models/ReportTarget.php b/src/models/ReportTarget.php
index a5df9ee..f808a1b 100644
--- a/src/models/ReportTarget.php
+++ b/src/models/ReportTarget.php
@@ -42,7 +42,9 @@ public function init()
$this->targetClass = Reports::$plugin->getTarget()->getDefaultTargetType();
}
- $this->settings = Json::decodeIfJson($this->settings);
+ if (\is_string($this->settings)) {
+ $this->settings = Json::decodeIfJson($this->settings);
+ }
}
/**
diff --git a/src/targets/EmailTarget.php b/src/targets/EmailTarget.php
index 1388934..66de56d 100644
--- a/src/targets/EmailTarget.php
+++ b/src/targets/EmailTarget.php
@@ -49,6 +49,7 @@ public function send(\superbig\reports\models\ReportTarget $target, array $repor
$message->setSubject($this->subject);
$variables = [
+ 'target' => $target,
'reports' => $reports,
];
$body = $view->renderString($this->body, $variables);
@@ -108,8 +109,6 @@ public function rules()
$rules = parent::rules();
$rules = array_merge($rules, [
[['subject'], 'required'],
- //[['apiKey'], 'default', 'value' => ''],
- //[['apiKey'], 'string'],
]);
return $rules;
diff --git a/src/templates/_targets/edit.twig b/src/templates/_targets/edit.twig
index 1da344a..1b05479 100644
--- a/src/templates/_targets/edit.twig
+++ b/src/templates/_targets/edit.twig
@@ -12,8 +12,7 @@
{% if currentUser.can('reports-create') %}