Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mark as read issue #23

Open
generalmroaerosapace opened this issue Jan 31, 2022 · 1 comment
Open

Mark as read issue #23

generalmroaerosapace opened this issue Jan 31, 2022 · 1 comment

Comments

@generalmroaerosapace
Copy link

I get an error when I try to mark as read any notification

mark as read issue

@generalmroaerosapace
Copy link
Author

//------------------AccountNotification---------------------

namespace app\notifications;

use Yii;
use webzop\notifications\Notification;

class AccountNotification extends Notification
{
const KEY_NEW_ACCOUNT = 'new_account';

const KEY_RESET_PASSWORD = 'reset_password';

const KEY_NEW_MESSAGE = 'new_message';

/**
 * @var \yii\web\User the user object
 */
public $user;

public $message;

/**
 * @inheritdoc
 */
public function getTitle(){
    switch($this->key){
        case self::KEY_NEW_ACCOUNT:
            return Yii::t('app', 'New account {user} created', ['user' => '#'.$this->user->id]);
        case self::KEY_RESET_PASSWORD:
            return Yii::t('app', 'Instructions to reset the password');
        case self::KEY_NEW_MESSAGE:
            return Yii::t('app', '{message}', ['message' => $this->message]);
    }
}

}

//------------Create a notification message---------------------

$user = User::findOne(['id' => $id]);
$notification = AccountNotification::create(AccountNotification::KEY_NEW_MESSAGE, ['user' => $user, 'message' => $model->message]);
$notification->setUserId($id);
$notification->send();

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant