Issues (15)

src/models/Notification.php (5 issues)

1
<?php
2
3
4
namespace tuyakhov\notifications\models;
5
6
7
use tuyakhov\notifications\behaviors\ReadableBehavior;
8
use yii\behaviors\TimestampBehavior;
9
use yii\db\ActiveRecord;
10
use yii\db\Expression;
11
12
/**
13
 * Database notification model
14
 * @property $level string
15
 * @property $subject string
16
 * @property $notifiable_type string
17
 * @property $notifiable_id int
18
 * @property $body string
19
 * @property $read_at string
20
 * @property $notifiable
21
 * @method  void markAsRead()
22
 * @method  void markAsUnread()
23
 * @method  bool read()
24
 * @method  bool unread()
25
 */
0 ignored issues
show
Documentation Bug introduced by Anton Tuyakhov
The doc comment $level at position 0 could not be parsed: Unknown type name '$level' at position 0 in $level.
Loading history...
26
class Notification extends ActiveRecord
27
{
28
29
    /**
30
     * @inheritdoc
31
     */
32
    public function rules()
33
    {
34
        return [
35
            [['level', 'notifiable_type', 'subject', 'body'], 'string'],
36
            ['notifiable_id', 'integer'],
37
        ];
38
    }
39
40
    /**
41
     * @inheritdoc
42
     */
43
    public function behaviors()
44
    {
45
        return [
46
            [
47
                'class' => TimestampBehavior::className(),
0 ignored issues
show
Deprecated Code introduced by Anton Tuyakhov
The function yii\base\BaseObject::className() has been deprecated: since 2.0.14. On PHP >=5.5, use `::class` instead. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

47
                'class' => /** @scrutinizer ignore-deprecated */ TimestampBehavior::className(),

This function has been deprecated. The supplier of the function has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.

Loading history...
48
                'value' => new Expression('NOW()'),
49
            ],
50
            ReadableBehavior::className()
0 ignored issues
show
Deprecated Code introduced by Anton Tuyakhov
The function yii\base\BaseObject::className() has been deprecated: since 2.0.14. On PHP >=5.5, use `::class` instead. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

50
            /** @scrutinizer ignore-deprecated */ ReadableBehavior::className()

This function has been deprecated. The supplier of the function has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.

Loading history...
51
        ];
52
    }
53
54
    public function getNotifiable()
55
    {
56
        return $this->hasOne($this->notifiable_type, ['id' => 'notifiable_id']);
0 ignored issues
show
Variable "notifiable_type" is not in valid camel caps format
Loading history...
Bug Best Practice introduced by Anton Tuyakhov
The property notifiable_type does not exist on tuyakhov\notifications\models\Notification. Since you implemented __get, consider adding a @property annotation.
Loading history...
57
    }
58
}