Code Duplication    Length = 7-8 lines in 15 locations

app/Location.php 2 locations

@@ 90-96 (lines=7) @@
87
     *
88
     * @return string
89
     */
90
    public function getUpdatedAtHumanAttribute()
91
    {
92
        if ($this->updated_at->diffInDays() > 0) {
93
                    return $this->updated_at->setTimezone(Auth::user()->timezone)->format('M d, Y h:i a');
94
        } else {
95
                    return $this->updated_at->diffForHumans();
96
        }
97
    }
98
    
99
    /**
@@ 109-115 (lines=7) @@
106
     *
107
     * @return string
108
     */
109
    public function getCreatedAtHumanAttribute()
110
    {
111
        if ($this->created_at->diffInDays() > 0) {
112
                    return $this->created_at->setTimezone(Auth::user()->timezone)->format('M d, Y h:i a');
113
        } else {
114
                    return $this->created_at->diffForHumans();
115
        }
116
    }
117
}
118

app/Sensor.php 2 locations

@@ 146-152 (lines=7) @@
143
     *
144
     * @return string
145
     */
146
    public function getUpdatedAtHumanAttribute()
147
    {
148
        if ($this->updated_at->diffInDays() > 0) {
149
                    return $this->updated_at->setTimezone(Auth::user()->timezone)->format('M d, Y h:i a');
150
        } else {
151
                    return $this->updated_at->diffForHumans();
152
        }
153
    }
154
    
155
    /**
@@ 165-171 (lines=7) @@
162
     *
163
     * @return string
164
     */
165
    public function getCreatedAtHumanAttribute()
166
    {
167
        if ($this->created_at->diffInDays() > 0) {
168
                    return $this->created_at->setTimezone(Auth::user()->timezone)->format('M d, Y h:i a');
169
        } else {
170
                    return $this->created_at->diffForHumans();
171
        }
172
    }
173
}

app/SensorData.php 2 locations

@@ 68-74 (lines=7) @@
65
     *
66
     * @return string
67
     */
68
    public function getUpdatedAtHumanAttribute()
69
    {
70
        if ($this->updated_at->diffInDays() > 0) {
71
                    return $this->updated_at->setTimezone(Auth::user()->timezone)->format('M d, Y h:i a');
72
        } else {
73
                    return $this->updated_at->diffForHumans();
74
        }
75
    }
76
    
77
    /**
@@ 87-93 (lines=7) @@
84
     *
85
     * @return string
86
     */
87
    public function getCreatedAtHumanAttribute()
88
    {
89
        if ($this->created_at->diffInDays() > 0) {
90
                    return $this->created_at->setTimezone(Auth::user()->timezone)->format('M d, Y h:i a');
91
        } else {
92
                    return $this->created_at->diffForHumans();
93
        }
94
    }
95
}

app/Site.php 2 locations

@@ 78-84 (lines=7) @@
75
     *
76
     * @return string
77
     */
78
    public function getUpdatedAtHumanAttribute()
79
    {
80
        if ($this->updated_at->diffInDays() > 0) {
81
                    return $this->updated_at->setTimezone(Auth::user()->timezone)->format('M d, Y h:i a');
82
        } else {
83
                    return $this->updated_at->diffForHumans();
84
        }
85
    }
86
    
87
    /**
@@ 97-103 (lines=7) @@
94
     *
95
     * @return string
96
     */
97
    public function getCreatedAtHumanAttribute()
98
    {
99
        if ($this->created_at->diffInDays() > 0) {
100
                    return $this->created_at->setTimezone(Auth::user()->timezone)->format('M d, Y h:i a');
101
        } else {
102
                    return $this->created_at->diffForHumans();
103
        }
104
    }
105
}
106

app/User.php 3 locations

@@ 166-172 (lines=7) @@
163
     *
164
     * @return string
165
     */
166
    public function getUpdatedAtHumanAttribute()
167
    {
168
        if ($this->updated_at->diffInDays() > 0) {
169
                    return $this->updated_at->setTimezone(Auth::user()->timezone)->format('M d, Y h:i a');
170
        } else {
171
                    return $this->updated_at->diffForHumans();
172
        }
173
    }
174
    
175
    /**
@@ 185-191 (lines=7) @@
182
     *
183
     * @return string
184
     */
185
    public function getCreatedAtHumanAttribute()
186
    {
187
        if ($this->created_at->diffInDays() > 0) {
188
                    return $this->created_at->setTimezone(Auth::user()->timezone)->format('M d, Y h:i a');
189
        } else {
190
                    return $this->created_at->diffForHumans();
191
        }
192
    }
193
    
194
    /**
@@ 204-211 (lines=8) @@
201
     *
202
     * @return string
203
     */
204
    public function getDeletedAtHumanAttribute()
205
    {
206
        if ($this->deleted_at->diffInDays() > 0) {
207
            return $this->deleted_at->setTimezone(Auth::user()->timezone)->format('M d, Y h:i a');
208
        } else {
209
            return $this->deleted_at->diffForHumans();
210
        }
211
    }
212
}
213

app/Device.php 4 locations

@@ 214-220 (lines=7) @@
211
     *
212
     * @return string
213
     */
214
    public function getLastNetworkUpdateAtHumanAttribute()
215
    {
216
        if ($this->last_network_update_at->diffInDays() > 0) {
217
                    return $this->last_network_update_at->setTimezone(Auth::user()->timezone)->format('M d, Y h:i a');
218
        } else {
219
                    return $this->last_network_update_at->diffForHumans();
220
        }
221
    }
222
    
223
    /**
@@ 233-239 (lines=7) @@
230
     *
231
     * @return string
232
     */
233
    public function getUpdatedAtHumanAttribute()
234
    {
235
        if ($this->updated_at->diffInDays() > 0) {
236
                    return $this->updated_at->setTimezone(Auth::user()->timezone)->format('M d, Y h:i a');
237
        } else {
238
                    return $this->updated_at->diffForHumans();
239
        }
240
    }
241
    
242
    /**
@@ 251-257 (lines=7) @@
248
     *
249
     * @return string
250
     */
251
    public function getCreatedAtHumanAttribute()
252
    {
253
        if ($this->created_at->diffInDays() > 0) {
254
                    return $this->created_at->setTimezone(Auth::user()->timezone)->format('M d, Y h:i a');
255
        } else {
256
                    return $this->created_at->diffForHumans();
257
        }
258
    }
259
    
260
    /**
@@ 269-276 (lines=8) @@
266
     *
267
     * @return string
268
     */
269
    public function getDeletedAtHumanAttribute()
270
    {
271
        if ($this->deleted_at->diffInDays() > 0) {
272
            return $this->deleted_at->setTimezone(Auth::user()->timezone)->format('M d, Y h:i a');
273
        } else {
274
            return $this->deleted_at->diffForHumans();
275
        }
276
    }
277
    
278
    /**
279
     * Scope a query to only include devices belonging to a given location