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