Notification
last analyzed

Complexity

Total Complexity 0

Size/Duplication

Total Lines 129
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
dl 0
loc 129
c 0
b 0
f 0
wmc 0
lcom 0
cbo 0
1
<?php
2
3
// @todo
4
5
namespace Transmissor\Models;
6
7
use App\Contants\Tables;
8
use Illuminate\Database\Eloquent\Collection;
9
use App\Models\Model;
0 ignored issues
show
Bug introduced by
This use statement conflicts with another class in this namespace, Transmissor\Models\Model.

Let’s assume that you have a directory layout like this:

.
|-- OtherDir
|   |-- Bar.php
|   `-- Foo.php
`-- SomeDir
    `-- Foo.php

and let’s assume the following content of Bar.php:

// Bar.php
namespace OtherDir;

use SomeDir\Foo; // This now conflicts the class OtherDir\Foo

If both files OtherDir/Foo.php and SomeDir/Foo.php are loaded in the same runtime, you will see a PHP error such as the following:

PHP Fatal error:  Cannot use SomeDir\Foo as Foo because the name is already in use in OtherDir/Foo.php

However, as OtherDir/Foo.php does not necessarily have to be loaded and the error is only triggered if it is loaded before OtherDir/Bar.php, this problem might go unnoticed for a while. In order to prevent this error from surfacing, you must import the namespace with a different alias:

// Bar.php
namespace OtherDir;

use SomeDir\Foo as SomeDirFoo; // There is no conflict anymore.
Loading history...
10
11
use Population\Manipule\Entities\NotificationEntity;
12
use Population\Manipule\Builders\NotificationBuilder;
13
14
/**
15
 * Class Notification.
16
 *
17
 * @property int id
18
 * @property string value
19
 * @property Collection posts
20
 * @package  App\Models
21
 */
22
class Notification extends Model
23
{
24
    public $table = "notifications";
25
26
    public $primaryKey = "id";
27
28
    public $timestamps = true;
29
30
    public $fillable = [
31
        'user_id',
32
        'flag',
33
        'uuid',
34
        'title',
35
        'details',
36
        'is_read',
37
    ];
38
39
    public $rules = [
40
        'title' => 'required',
41
        'details' => 'required',
42
        'flag' => 'required',
43
        'user_id' => 'required',
44
    ];
45
    // /**
46
    //  * @inheritdoc
47
    //  */
48
    // public $timestamps = false;
49
50
    // /**
51
    //  * @inheritdoc
52
    //  */
53
    // protected $fillable = [
54
    //     'value',
55
    // ];
56
57
    // public function types()
58
    // {
59
    //     return [
60
    //         'newSubscription' => [
61
    //             'title' => 'Novo inscrito',
62
    //             'text' => '{name} se cadastrou no seu site!',
63
    //             'url' => '/admin/subscription/'
64
    //         ],
65
    //         'newMessage' => [
66
    //             'title' => 'Nova Mensagem',
67
    //             'text' => '{name} te enviou uma mensagem!',
68
    //             'url' => '/messages/{id}'
69
    //         ],
70
    //     ];
71
    // }
72
73
    // /**
74
    //  * Gera uma Nova Notificação para o Alvo
75
    //  *
76
    //  * @param  [type] $target
77
    //  * @param  [type] $typeNotification
78
    //  * @param  array  $data
79
    //  * @return void
80
    //  */
81
    // public static function generate($target, $typeNotification, $data = [])
82
    // {
83
    //     // @todo
84
    //     // self::create([
85
86
    //     // ]);
87
    // }
88
89
    // /**
90
    //  * @inheritdoc
91
    //  */
92
    // public static function boot()
93
    // {
94
    //     parent::boot();
95
96
    //     static::deleting(
97
    //         function (self $tag) {
98
    //             $tag->posts()->detach();
99
    //         }
100
    //     );
101
    // }
102
103
    // /**
104
    //  * @inheritdoc
105
    //  */
106
    // public function newEloquentBuilder($query): NotificationBuilder
107
    // {
108
    //     return new NotificationBuilder($query);
109
    // }
110
111
    // /**
112
    //  * @inheritdoc
113
    //  */
114
    // public function newQuery(): NotificationBuilder
115
    // {
116
    //     return parent::newQuery();
117
    // }
118
119
    // /**
120
    //  * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany
121
    //  */
122
    // public function posts()
123
    // {
124
    //     return $this->belongsToMany(Post::class, Tables::TABLE_POSTS_TAGS);
125
    // }
126
127
    // /**
128
    //  * Setter for the 'value' attribute.
129
    //  *
130
    //  * @param  string $value
131
    //  * @return $this
132
    //  */
133
    // public function setValueAttribute(string $value)
134
    // {
135
    //     $this->attributes['value'] = trim(str_replace(' ', '_', strtolower($value)));
136
137
    //     return $this;
138
    // }
139
140
    // /**
141
    //  * @return NotificationEntity
142
    //  */
143
    // public function toEntity(): NotificationEntity
144
    // {
145
    //     return new NotificationEntity([
146
    //         'id' => $this->id,
147
    //         'value' => $this->value,
148
    //     ]);
149
    // }
150
}
151