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

Raza
Raza

i'm having problem developing octobercms backend. currently i have 2 model :

  1. User
  2. UserRole

in the user model, i have afterSave() event :

public function afterSave()
{
$db_role = new UserRole;
$db_role ->unbindEvent( 'model.afterSave' );
$db_role->user_id = $this->id;
$db_role->role_id = 1;
$db_role->save()
}

in the user_role model i have afterSave() event too.

public function afterSave()
{
if( $this->role_id == 1 )
{
$db_user->status = true;
$db_user->save();
}
}
this event forcing my $db_user current status to TRUE;

the problem is i dont want afterSave() event in USER ROLE MODEL to be called when im saving in USER MODEL.

i tried using $this->unbindEvent( 'model.afterSave' ), it didnt work too.
Anyone know how to stop octoberCms from calling unnecessary event, or is it other way like saving in Controller ?
thanks

Last updated

mltefive63033
mltefive63033

public function beforeSave() { $this->color = "green"; }

1-2 of 2

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