• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

conedevelopment / root / 15084089635

17 May 2025 10:00AM UTC coverage: 77.93% (+0.04%) from 77.891%
15084089635

push

github

web-flow
Modernize back-end.yml (#240)

3291 of 4223 relevant lines covered (77.93%)

36.04 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

88.89
/src/Models/Notification.php
1
<?php
2

3
namespace Cone\Root\Models;
4

5
use Cone\Root\Database\Factories\NotificationFactory;
6
use Cone\Root\Interfaces\Models\Notification as Contract;
7
use Cone\Root\Root;
8
use Cone\Root\Traits\InteractsWithProxy;
9
use Illuminate\Database\Eloquent\Casts\Attribute;
10
use Illuminate\Database\Eloquent\Concerns\HasUuids;
11
use Illuminate\Database\Eloquent\Factories\HasFactory;
12
use Illuminate\Notifications\DatabaseNotification;
13
use Illuminate\Support\Facades\URL;
14

15
class Notification extends DatabaseNotification implements Contract
16
{
17
    use HasFactory;
18
    use HasUuids;
19
    use InteractsWithProxy;
20

21
    /**
22
     * The accessors to append to the model's array form.
23
     *
24
     * @var list<string>
25
     */
26
    protected $appends = [
27
        'formatted_created_at',
28
        'is_read',
29
        'url',
30
    ];
31

32
    /**
33
     * The table associated with the model.
34
     *
35
     * @var string
36
     */
37
    protected $table = 'root_notifications';
38

39
    /**
40
     * Create a new factory instance for the model.
41
     */
42
    protected static function newFactory(): NotificationFactory
6✔
43
    {
44
        return NotificationFactory::new();
6✔
45
    }
46

47
    /**
48
     * Get the proxied interface.
49
     */
50
    public static function getProxiedInterface(): string
1✔
51
    {
52
        return Contract::class;
1✔
53
    }
54

55
    /**
56
     * {@inheritdoc}
57
     */
58
    public function getMorphClass(): string
×
59
    {
60
        return static::getProxiedClass();
×
61
    }
62

63
    /**
64
     * Get the formatted created at attribute.
65
     *
66
     * @return \Illuminate\Database\Eloquent\Casts\Attribute<string|null, never>
67
     */
68
    protected function formattedCreatedAt(): Attribute
3✔
69
    {
70
        return new Attribute(
3✔
71
            get: fn (): ?string => $this->created_at?->setTimezone(Root::instance()->getTimezone())?->isoFormat('YYYY. MMMM DD. HH:mm')
3✔
72
        );
3✔
73
    }
74

75
    /**
76
     * Get the is read at attribute.
77
     *
78
     * @return \Illuminate\Database\Eloquent\Casts\Attribute<bool, never>
79
     */
80
    protected function isRead(): Attribute
3✔
81
    {
82
        return new Attribute(
3✔
83
            get: fn (): bool => ! is_null($this->read_at)
3✔
84
        );
3✔
85
    }
86

87
    /**
88
     * Get the URL attribute.
89
     *
90
     * @return \Illuminate\Database\Eloquent\Casts\Attribute<string|null, never>
91
     */
92
    protected function url(): Attribute
3✔
93
    {
94
        return new Attribute(
3✔
95
            get: fn (): ?string => $this->exists ? URL::route('root.api.notifications.update', $this) : null
3✔
96
        );
3✔
97
    }
98
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc