This forum has moved to a new location and is in read-only mode. Please visit talk.octobercms.com to access the new location.

4nik3t
4nik3t

I have created a beforeCreate() function inside my model. The thing which i want to do is If I have a record existing with the email I want to update the same record instead of creating a new record. Here is the code I am trying to execute .

public function beforeCreate() { $subscriber= static::firstOrNew(["email"=>$this->email]); $subscriber->valid_till = " ....."; $subscriber->save(); return false; }

I am getting a javascript alert with text "error" . Any better way of doing this better.

Last updated

1-1 of 1

You cannot edit posts or make replies: the forum has moved to talk.octobercms.com.