Pass Model In Beforesave

Hello everyone.

I have a model called “Ticket”. Within the Ticket model in the “beforeSave” I have a function call. I’ll just give you the code :)




public function beforeSave() {

...

// this here is working

Notification::sendToClient(Ticket::model()->findByPk($this->id));


// and this here is not

Notification::sendToClient($this);


fun sendToClient($model) {

    die($model->client->id);

}

// the id is different and i don't understand why



I can give you more details about what exactly is going wrong but this might be something trivial so i’ll just keep the stuff that’s not interesting to anyone to myself.

Could you please tell me in which class you are defining this method definition.




fun sendToClient($model) {

    die($model->client->id);

}



By the way you can use a clone of $this and pass it to your method if it is creating issue there and lets try it.