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

Problem after update - new field flashed #36

Open
ilbassa opened this issue Jul 18, 2017 · 3 comments
Open

Problem after update - new field flashed #36

ilbassa opened this issue Jul 18, 2017 · 3 comments

Comments

@ilbassa
Copy link

ilbassa commented Jul 18, 2017

The notification aren't shown, seems that is missing 'flashed' in the rules()
[['id', 'key_id', 'created_at'], 'safe'],
changed in
[['id', 'key_id', 'created_at', 'flashed'], 'safe'],
now it shows all the notification

@machour
Copy link
Owner

machour commented Jul 18, 2017

Could you give a complete reproduce case ? this works for me, flashed gets set to 1 without being in rules() (so does seen)

@ilbassa
Copy link
Author

ilbassa commented Jul 18, 2017

Hi, we have tested deeper the code.
The problem isn't in the model, but in the poll action.
ORACLE doesn't manage boolean value in the db so we must use INTEGER dataType with 0/1 values.

The notification are displayed with this modifications:

        $seen = $seen ? 1 : 0;
        /** @var Notification $class */
        $class = $this->notificationClass;
        $models = $class::find()
            ->where(['user_id' => $this->user_id])
            ->andWhere(['or', '"seen"='.$seen, '"flashed"=0'])
            ->orderBy('created_at DESC')
            ->all();

@ilbassa
Copy link
Author

ilbassa commented Jul 18, 2017

Hi, finally we have figured it out.

The double quotes are required from ORACLE but it is better that the management of this is demanded to connection to the db, so the first correction we made is wrap the condition around []
``
$seen = $seen ? 1 : 0;

   ->andWhere(['or',` ['seen'=>$seen] ,['flashed'=>0]])

``

I have override the notify() function because I needed to return the instance of the notfication, so I have added the 'flashed'=>0 default value when saving a new notification.
And now it works.

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

No branches or pull requests

2 participants