Issues (209)

src/Foundation/Traits/HasDatabaseNotifications.php (2 issues)

Labels
Severity
1
<?php
2
/**
3
 * Created by PhpStorm.
4
 * User: arthur
5
 * Date: 14.10.18
6
 * Time: 18:37.
7
 */
8
9
namespace Foundation\Traits;
10
11
trait HasDatabaseNotifications
12
{
13
    /**
14
     * Get the entity's notifications.
15
     */
16
    public function notifications()
17
    {
18
        if (env('DB_CONNECTION') === 'mongodb') {
19
            $notificationClass = \Foundation\Models\MongoDatabaseNotification::class;
0 ignored issues
show
The type Foundation\Models\MongoDatabaseNotification was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
20
        } else {
21
            $notificationClass = \Illuminate\Notifications\DatabaseNotification::class;
22
        }
23
24
        return $this->morphMany($notificationClass, 'notifiable')
0 ignored issues
show
It seems like morphMany() must be provided by classes using this trait. How about adding it as abstract method to this trait? ( Ignorable by Annotation )

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

24
        return $this->/** @scrutinizer ignore-call */ morphMany($notificationClass, 'notifiable')
Loading history...
25
            ->orderBy('created_at', 'desc');
26
    }
27
28
    /**
29
     * Get the entity's read notifications.
30
     */
31
    public function readNotifications()
32
    {
33
        return $this->notifications()
34
            ->whereNotNull('read_at');
35
    }
36
37
    /**
38
     * Get the entity's unread notifications.
39
     */
40
    public function unreadNotifications()
41
    {
42
        return $this->notifications()
43
            ->whereNull('read_at');
44
    }
45
}
46