Code Duplication    Length = 51-51 lines in 2 locations

src/Notifynder/Traits/Notifable.php 1 location

@@ 10-60 (lines=51) @@
7
/**
8
 * Class Notifable.
9
 */
10
trait Notifable
11
{
12
    use NotifableBasic;
13
14
    /**
15
     * Define a polymorphic one-to-many relationship.
16
     *
17
     * @param  string  $related
18
     * @param  string  $name
19
     * @param  string  $type
20
     * @param  string  $id
21
     * @param  string  $localKey
22
     * @return \Illuminate\Database\Eloquent\Relations\MorphMany
23
     */
24
    abstract public function morphMany($related, $name, $type = null, $id = null, $localKey = null);
25
26
    /**
27
     * Define a one-to-many relationship.
28
     *
29
     * @param  string  $related
30
     * @param  string  $foreignKey
31
     * @param  string  $localKey
32
     * @return \Illuminate\Database\Eloquent\Relations\HasMany
33
     */
34
    abstract public function hasMany($related, $foreignKey = null, $localKey = null);
35
36
    /**
37
     * Get the notifications Relationship.
38
     *
39
     * @return \Illuminate\Database\Eloquent\Relations\HasMany|\Illuminate\Database\Eloquent\Relations\MorphMany
40
     */
41
    public function notifications()
42
    {
43
        $model = app('notifynder.resolver.model')->getModel(Notification::class);
44
        if (notifynder_config()->isPolymorphic()) {
45
            return $this->morphMany($model, 'to');
46
        }
47
48
        return $this->hasMany($model, 'to_id');
49
    }
50
51
    /**
52
     * Get the notifications Relationship without any eager loading.
53
     *
54
     * @return \Illuminate\Database\Eloquent\Relations\HasMany|\Illuminate\Database\Eloquent\Relations\MorphMany
55
     */
56
    public function getLazyNotificationRelation()
57
    {
58
        return $this->notifications();
59
    }
60
}
61

src/Notifynder/Traits/NotifableLaravel53.php 1 location

@@ 10-60 (lines=51) @@
7
/**
8
 * Class Notifable.
9
 */
10
trait NotifableLaravel53
11
{
12
    use NotifableBasic;
13
14
    /**
15
     * Define a polymorphic one-to-many relationship.
16
     *
17
     * @param  string  $related
18
     * @param  string  $name
19
     * @param  string  $type
20
     * @param  string  $id
21
     * @param  string  $localKey
22
     * @return \Illuminate\Database\Eloquent\Relations\MorphMany
23
     */
24
    abstract public function morphMany($related, $name, $type = null, $id = null, $localKey = null);
25
26
    /**
27
     * Define a one-to-many relationship.
28
     *
29
     * @param  string  $related
30
     * @param  string  $foreignKey
31
     * @param  string  $localKey
32
     * @return \Illuminate\Database\Eloquent\Relations\HasMany
33
     */
34
    abstract public function hasMany($related, $foreignKey = null, $localKey = null);
35
36
    /**
37
     * Get the notifications Relationship.
38
     *
39
     * @return \Illuminate\Database\Eloquent\Relations\HasMany|\Illuminate\Database\Eloquent\Relations\MorphMany
40
     */
41
    public function notifynderNotifications()
42
    {
43
        $model = app('notifynder.resolver.model')->getModel(Notification::class);
44
        if (notifynder_config()->isPolymorphic()) {
45
            return $this->morphMany($model, 'to');
46
        }
47
48
        return $this->hasMany($model, 'to_id');
49
    }
50
51
    /**
52
     * Get the notifications Relationship without any eager loading.
53
     *
54
     * @return \Illuminate\Database\Eloquent\Relations\HasMany|\Illuminate\Database\Eloquent\Relations\MorphMany
55
     */
56
    public function getLazyNotificationRelation()
57
    {
58
        return $this->notifynderNotifications();
59
    }
60
}
61