Passed
Push — task/classification-accessor ( 93fb9b...740ae8 )
by Yonathan
14:49 queued 04:55
created

Manager::getIsDemoManagerAttribute()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 3
dl 0
loc 6
rs 10
c 0
b 0
f 0
cc 2
nc 2
nop 0
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 $division
45
 * @property string $position
46
 * @property string $leadership_style
47
 * @property string $employee_learning
48
 * @property string $expectations
49
 * @property string $education
50
 * @property string $career_journey
51
 * @property string $learning_path
52
 *
53
 * Computed Properties
54
 * @property string $name
55
 * @property boolean $is_demo_manager
56
 *
57
 * Methods
58
 * @method   string toApiArray()
59
 */
60
class Manager extends BaseModel
61
{
62
    use Translatable;
0 ignored issues
show
Bug introduced by
The trait Astrotomic\Translatable\Translatable requires the property $each which is not provided by App\Models\Manager.
Loading history...
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
        'division',
70
        'position',
71
        'leadership_style',
72
        'employee_learning',
73
        'expectations',
74
        'education',
75
        'career_journey',
76
        'learning_path'
77
    ];
78
    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...
79
        'department_id' => 'int',
80
        'user_id' => 'int'
81
    ];
82
    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...
83
        'department_id',
84
        'twitter_username',
85
        'linkedin_url',
86
        'work_review_frequency_id',
87
        'stay_late_frequency_id',
88
        'engage_team_frequency_id',
89
        'development_opportunity_frequency_id',
90
        'refuse_low_value_work_frequency_id',
91
        'years_experience'
92
    ];
93
94
    /**
95
     * The accessors to append to the model's array form.
96
     *
97
     * @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...
98
     */
99
    protected $appends = ['name', 'is_demo_manager'];
100
101
    /**
102
     * The attributes that should be visible in arrays.
103
     *
104
     * @var array
0 ignored issues
show
introduced by
@var annotation of property \App\Models\Manager::$visible does not specify type hint for its items.
Loading history...
105
     */
106
    protected $visible = [
107
        'id',
108
        'user_id',
109
        'name',
110
        'department_id',
111
        'twitter_username',
112
        'linkedin_url',
113
        'is_demo_manager'
114
    ];
115
116
    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...
117
    {
118
        return $this->belongsTo(\App\Models\User::class);
119
    }
120
121
    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...
122
    {
123
        return $this->belongsTo(\App\Models\Lookup\Department::class);
124
    }
125
126
    public function job_posters() //phpcs:ignore
127
    {
128
        return $this->hasMany(\App\Models\JobPoster::class);
129
    }
130
131
    public function work_environment() //phpcs:ignore
132
    {
133
        return $this->hasOne(\App\Models\WorkEnvironment::class)->withDefault();
134
    }
135
136
    public function team_culture() //phpcs:ignore
137
    {
138
        return $this->hasOne(\App\Models\TeamCulture::class)->withDefault();
139
    }
140
    /*
141
    * @property \App\Models\Lookup\Frequency $review_options
142
    * @property \App\Models\Lookup\Frequency $staylate
143
    * @property \App\Models\Lookup\Frequency $engage
144
    * @property \App\Models\Lookup\Frequency $opportunities
145
    * @property \App\Models\Lookup\Frequency $low_value_work_requests
146
    *
147
    * work_review_frequency
148
    * stay_late_frequency
149
    * engage_team_frequency
150
    * development_opportunity_frequency
151
    * refuse_low_value_work_frequency
152
    */
153
    public function work_review_frequency() //phpcs:ignore
154
    {
155
        return $this->belongsTo(\App\Models\Lookup\Frequency::class);
156
    }
157
158
    public function stay_late_frequency() //phpcs:ignore
159
    {
160
        return $this->belongsTo(\App\Models\Lookup\Frequency::class);
161
    }
162
163
    public function engage_team_frequency() //phpcs:ignore
164
    {
165
        return $this->belongsTo(\App\Models\Lookup\Frequency::class);
166
    }
167
168
    public function development_opportunity_frequency() //phpcs:ignore
169
    {
170
        return $this->belongsTo(\App\Models\Lookup\Frequency::class);
171
    }
172
173
    public function refuse_low_value_work_frequency() //phpcs:ignore
174
    {
175
        return $this->belongsTo(\App\Models\Lookup\Frequency::class);
176
    }
177
178
    /**
179
     * Return the full name of the User associated with this Manager.
180
     *
181
     * @return string
182
     */
183
    public function getNameAttribute(): string
184
    {
185
        if ($this->user !== null) {
186
            return $this->user->first_name . ' ' . $this->user->last_name;
187
        }
188
        return '';
189
    }
190
191
    /**
192
     * Return whether this is a Demo Manager.
193
     *
194
     * @return boolean
195
     */
196
    public function getIsDemoManagerAttribute(): bool
197
    {
198
        if ($this->user !== null) {
199
            return $this->user->isDemoManager();
200
        }
201
        return true;
202
    }
203
204
    /**
205
     * Return the array of values used to represent this object in an api response.
206
     * This array should contain no nested objects (besides translations).
207
     *
208
     * @return mixed[]
209
     */
210
    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...
211
    {
212
        $withTranslations = array_merge($this->toArray(), $this->getTranslationsArray());
213
        return $withTranslations;
214
    }
215
}
216