Passed
Push — dev ( c369d7...065231 )
by Chris
14:17 queued 05:41
created

Manager::getNameAttribute()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 0
Metric Value
eloc 3
dl 0
loc 6
ccs 0
cts 0
cp 0
rs 10
c 0
b 0
f 0
cc 2
nc 2
nop 0
crap 6
1
<?php
2
3
/**
4
 * Created by Reliese Model.
5
 * Date: Thu, 12 Jul 2018 22:39:27 +0000.
6
 */
7
8
namespace App\Models;
9
10
use App\CRUD\TalentCloudCrudTrait as CrudTrait;
11
use Astrotomic\Translatable\Translatable as Translatable;
12
13
/**
14
 * Class Manager
15
 *
16
 * @property int $id
17
 * @property int $department_id
18
 * @property int $work_review_frequency_id
19
 * @property int $stay_late_frequency_id
20
 * @property int $engage_team_frequency_id
21
 * @property int $development_opportunity_frequency_id
22
 * @property int $refuse_low_value_work_frequency_id
23
 * @property int $years_experience
24
 * @property string $twitter_username
25
 * @property string $linkedin_url
26
 * @property int $user_id
27
 * @property \Jenssegers\Date\Date $created_at
28
 * @property \Jenssegers\Date\Date $updated_at
29
 *
30
 * @property \App\Models\User $user
31
 * @property \App\Models\Lookup\Department $department
32
 * @property \Illuminate\Database\Eloquent\Collection $job_posters
33
 * @property \App\Models\WorkEnvironment $work_environment
34
 * @property \App\Models\TeamCulture $team_culture
35
 * @property \App\Models\Lookup\Frequency $work_review_frequency
36
 * @property \App\Models\Lookup\Frequency $stay_late_frequency
37
 * @property \App\Models\Lookup\Frequency $engage_team_frequency
38
 * @property \App\Models\Lookup\Frequency $development_opportunity_frequency
39
 * @property \App\Models\Lookup\Frequency $refuse_low_value_work_frequency
40
 *
41
 * Localized Properties:
42
 * @property string $about_me
43
 * @property string $greatest_accomplishment
44
 * @property string $branch
45
 * @property string $division
46
 * @property string $position
47
 * @property string $leadership_style
48
 * @property string $employee_learning
49
 * @property string $expectations
50
 * @property string $education
51
 * @property string $career_journey
52
 * @property string $learning_path
53
 *
54
 * Computed Properties
55
 * @property string $name
56
 *
57
 * Methods
58
 * @method string toApiArray()
59
 */
60
class Manager extends BaseModel
61
{
62
    use Translatable;
63
    // Trait for Backpack
64
    use CrudTrait;
0 ignored issues
show
introduced by
The trait App\CRUD\TalentCloudCrudTrait requires some properties which are not provided by App\Models\Manager: $Type, $fakeColumns
Loading history...
65
66
    public $translatedAttributes = [
1 ignored issue
show
introduced by
Property \App\Models\Manager::$translatedAttributes does not have @var annotation.
Loading history...
Coding Style Documentation introduced by
Missing member variable doc comment
Loading history...
67
        'about_me',
68
        'greatest_accomplishment',
69
        'branch',
70
        'division',
71
        'position',
72
        'leadership_style',
73
        'employee_learning',
74
        'expectations',
75
        'education',
76
        'career_journey',
77
        'learning_path'
78
    ];
79
    protected $casts = [
1 ignored issue
show
introduced by
Property \App\Models\Manager::$casts does not have @var annotation.
Loading history...
Coding Style Documentation introduced by
Missing member variable doc comment
Loading history...
80
        'department_id' => 'int',
81
        'user_id' => 'int'
82
    ];
83
    protected $fillable = [
1 ignored issue
show
introduced by
Property \App\Models\Manager::$fillable does not have @var annotation.
Loading history...
Coding Style Documentation introduced by
Missing member variable doc comment
Loading history...
84
        'department_id',
85
        'twitter_username',
86
        'linkedin_url',
87
        'work_review_frequency_id',
88
        'stay_late_frequency_id',
89
        'engage_team_frequency_id',
90
        'development_opportunity_frequency_id',
91
        'refuse_low_value_work_frequency_id',
92 39
        'years_experience'
93
    ];
94 39
95
    /**
96
     * The accessors to append to the model's array form.
97 6
     *
98
     * @var array
0 ignored issues
show
introduced by
@var annotation of property \App\Models\Manager::$appends does not specify type hint for its items.
Loading history...
99 6
     */
100
    protected $appends = ['name'];
101
102
    public function user()
1 ignored issue
show
introduced by
Method \App\Models\Manager::user() does not have return type hint nor @return annotation for its return value.
Loading history...
Coding Style Documentation introduced by
Missing doc comment for function user()
Loading history...
103
    {
104
        return $this->belongsTo(\App\Models\User::class);
105
    }
106
107 53
    public function department()
1 ignored issue
show
introduced by
Method \App\Models\Manager::department() does not have return type hint nor @return annotation for its return value.
Loading history...
Coding Style Documentation introduced by
Missing doc comment for function department()
Loading history...
108
    {
109 53
        return $this->belongsTo(\App\Models\Lookup\Department::class);
110
    }
111
112 53
    public function job_posters() //phpcs:ignore
113
    {
114 53
        return $this->hasMany(\App\Models\JobPoster::class);
115
    }
116
117
    public function work_environment() //phpcs:ignore
118
    {
119
        return $this->hasOne(\App\Models\WorkEnvironment::class)->withDefault();
120
    }
121
122
    public function team_culture() //phpcs:ignore
123
    {
124
        return $this->hasOne(\App\Models\TeamCulture::class)->withDefault();
125
    }
126
    /*
127
    * @property \App\Models\Lookup\Frequency $review_options
128
    * @property \App\Models\Lookup\Frequency $staylate
129
    * @property \App\Models\Lookup\Frequency $engage
130
    * @property \App\Models\Lookup\Frequency $opportunities
131
    * @property \App\Models\Lookup\Frequency $low_value_work_requests
132
    *
133
    * work_review_frequency
134
    * stay_late_frequency
135
    * engage_team_frequency
136
    * development_opportunity_frequency
137
    * refuse_low_value_work_frequency
138
    */
139
    public function work_review_frequency() //phpcs:ignore
140
    {
141
        return $this->belongsTo(\App\Models\Lookup\Frequency::class);
142
    }
143
144
    public function stay_late_frequency() //phpcs:ignore
145
    {
146
        return $this->belongsTo(\App\Models\Lookup\Frequency::class);
147
    }
148
149
    public function engage_team_frequency() //phpcs:ignore
150
    {
151
        return $this->belongsTo(\App\Models\Lookup\Frequency::class);
152
    }
153
154
    public function development_opportunity_frequency() //phpcs:ignore
155
    {
156
        return $this->belongsTo(\App\Models\Lookup\Frequency::class);
157
    }
158
159
    public function refuse_low_value_work_frequency() //phpcs:ignore
160 2
    {
161
        return $this->belongsTo(\App\Models\Lookup\Frequency::class);
162 2
    }
163 2
164
    /**
165
     * Return the name of the User associated with this Manager.
166
     *
167
     * @return string
168
     */
169
    public function getNameAttribute(): string
170
    {
171
        if ($this->user !== null) {
172
            return $this->user->name;
173
        }
174
        return '';
175
    }
176
177
    /**
178
     * Return the array of values used to represent this object in an api response.
179
     * This array should contain no nested objects (besides translations).
180
     *
181
     * @return mixed[]
182
     */
183
    public function toApiArray()
0 ignored issues
show
introduced by
Method \App\Models\Manager::toApiArray() does not have return type hint for its return value but it should be possible to add it based on @return annotation "mixed[]".
Loading history...
184
    {
185
        $withTranslations = array_merge($this->toArray(), $this->getTranslationsArray());
186
        return $withTranslations;
187
    }
188
}
189