I know it's very simple but I'm unable to resolve this. Please look into this.
I have a table called notification_updates and it's array is like this:
Array
(
[0] => common\models\NotificationUpdates Object
(
[_attributes:yii\db\BaseActiveRecord:private] => Array
(
[id] => 1
[title] => This is the notification to inform you about this.
[status] => 1
[created_at] => 2017-11-20 08:29:21
)
)
[1] => common\models\NotificationUpdates Object
(
[_attributes:yii\db\BaseActiveRecord:private] => Array
(
[id] => 2
[title] => This is the notification to inform you about this cricket match
[status] => 1
[created_at] => 2017-11-20 06:24:09
)
)
[2] => common\models\NotificationUpdates Object
(
[_attributes:yii\db\BaseActiveRecord:private] => Array
(
[id] => 3
[title] => Inform you about this cricket match
[status] => 1
[created_at] => 2017-11-21 11:40:31
)
)
)
Now I have 1 more table where primary_key (id) of first table is foriegn called notification_id in table deleted_nofitication.
This table also has array like this:
Array
(
[0] => common\models\DeletedNofitication Object
(
[_attributes:yii\db\BaseActiveRecord:private] => Array
(
[notification_id] => 1
)
)
[1] => common\models\DeletedNofitication Object
(
[_attributes:yii\db\BaseActiveRecord:private] => Array
(
[notification_id] => 2
)
)
)
Now I have to check weather notification_updates table have this value against that user_id. If it's there then it should not that notification should not be displayed under JSON.
I have Done like this in PHP (YII2) - not doing compare in this please check
$notifications = NotificationUpdates::find()->where([])->all();
$outt = [];
foreach($notifications as $notification) {
$deleted_notification = DeletedNofitication::find()
->select('notification_id')
->where(['user_id'=>$user_id])
->all();
$outt[] = [
'id' => $notification->id,
'notification_title' => $notification->title
];
}
$out = [
'notification'=> $outt,
'success' => true,
'message' => 'All Notification Updates'
];