Major update of unit tests / updated routers + models + react
This commit is contained in:
@ -8,6 +8,10 @@ class Newsletter extends Model {
|
||||
|
||||
function __construct() {
|
||||
parent::__construct();
|
||||
|
||||
$this->addValidations('type', array(
|
||||
'required' => __('You need to specify a type.')
|
||||
));
|
||||
}
|
||||
|
||||
function save() {
|
||||
@ -15,9 +19,23 @@ class Newsletter extends Model {
|
||||
$this->set_expr('deleted_at', 'NULL');
|
||||
}
|
||||
|
||||
$this->set('body',
|
||||
is_array($this->body)
|
||||
? json_encode($this->body)
|
||||
: $this->body
|
||||
);
|
||||
return parent::save();
|
||||
}
|
||||
|
||||
function asArray() {
|
||||
$model = parent::asArray();
|
||||
|
||||
if(isset($model['body'])) {
|
||||
$model['body'] = json_decode($model['body'], true);
|
||||
}
|
||||
return $model;
|
||||
}
|
||||
|
||||
function delete() {
|
||||
// delete all relations to segments
|
||||
NewsletterSegment::where('newsletter_id', $this->id)->deleteMany();
|
||||
|
Reference in New Issue
Block a user