Event   A
last analyzed

Complexity

Total Complexity 11

Size/Duplication

Total Lines 67
Duplicated Lines 0 %

Importance

Changes 4
Bugs 0 Features 2
Metric Value
eloc 26
c 4
b 0
f 2
dl 0
loc 67
rs 10
wmc 11

9 Methods

Rating   Name   Duplication   Size   Complexity  
A getDescriptionAttribute() 0 3 1
A guests() 0 3 1
A getImageDimensions() 0 3 1
A getPublishedAttribute() 0 3 1
A getFileName() 0 3 1
A getNameAttribute() 0 3 1
A scopePublished() 0 6 2
A filesDir() 0 3 1
A getAvatarAttribute() 0 8 2
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