Event::getNameAttribute()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 3
rs 10
1
<?php
2
3
namespace Innoflash\Events\Models;
4
5
use FaithGen\SDK\Models\UuidModel;
6
use FaithGen\SDK\SDK;
0 ignored issues
show
Bug introduced by
The type FaithGen\SDK\SDK 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...
7
use FaithGen\SDK\Traits\Relationships\Belongs\BelongsToMinistryTrait;
8
use FaithGen\SDK\Traits\Relationships\Morphs\CommentableTrait;
9
use FaithGen\SDK\Traits\Relationships\Morphs\ImageableTrait;
10
use FaithGen\SDK\Traits\StorageTrait;
11
12
class Event extends UuidModel
13
{
14
    use BelongsToMinistryTrait, CommentableTrait, ImageableTrait, StorageTrait;
15
16
    protected $table = 'fg_events';
17
    protected $casts = [
18
        'location' => 'array',
19
    ];
20
21
    protected $hidden = [
22
        'ministry_id',
23
        'created_at',
24
        'updated_at',
25
    ];
26
27
    public function guests()
28
    {
29
        return $this->hasMany(Guest::class);
30
    }
31
32
    public function getNameAttribute($val)
33
    {
34
        return ucwords($val);
35
    }
36
37
    public function getDescriptionAttribute($val)
38
    {
39
        return ucfirst($val);
40
    }
41
42
    public function scopePublished($query)
43
    {
44
        if (! config('faithgen-sdk.source')) {
45
            return $query->wherePublished(true);
46
        } else {
47
            return $query;
48
        }
49
    }
50
51
    public function getPublishedAttribute($val)
52
    {
53
        return (bool) $val;
54
    }
55
56
    public function filesDir()
57
    {
58
        return 'events';
59
    }
60
61
    public function getFileName()
62
    {
63
        return $this->image->name;
0 ignored issues
show
Bug introduced by
The property image does not seem to exist on Innoflash\Events\Models\Event. Are you sure there is no database migration missing?

Checks if undeclared accessed properties appear in database migrations and if the creating migration is correct.

Loading history...
64
    }
65
66
    public function getImageDimensions()
67
    {
68
        return [0, 50];
69
    }
70
71
    public function getAvatarAttribute()
72
    {
73
        if (! $this->image()->exists()) {
74
            return;
75
        } else {
76
            return [
77
                '_50' => SDK::getAsset('storage/events/50-50/'.$this->image->name),
0 ignored issues
show
Bug introduced by
The property image does not seem to exist on Innoflash\Events\Models\Event. Are you sure there is no database migration missing?

Checks if undeclared accessed properties appear in database migrations and if the creating migration is correct.

Loading history...
78
                'original' => SDK::getAsset('storage/events/original/'.$this->image->name),
79
            ];
80
        }
81
    }
82
}
83