Humanresource   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 47
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 71.43%

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 1
dl 0
loc 47
ccs 5
cts 7
cp 0.7143
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A business() 0 4 1
A setCalendarLinkAttribute() 0 4 2
A save() 0 6 1
1
<?php
2
3
namespace Timegridio\Concierge\Models;
4
5
use Illuminate\Database\Eloquent\Model as EloquentModel;
6
use Illuminate\Database\Eloquent\Relations\BelongsTo;
7
8
/**
9
 * @property int $id
10
 * @property string $name
11
 * @property int $business_id
12
 * @property Timegridio\Concierge\Models\business $business
13
 * @property int $capacity
14
 * @property string $slug
15
 * @property string $calendar_link
16
 */
17
class Humanresource extends EloquentModel
18
{
19
    /**
20
     * The attributes that are mass assignable.
21
     *
22
     * @var array
23
     */
24
    protected $fillable = ['name', 'capacity', 'calendar_link'];
25
26
    protected $guarded = ['id', 'slug'];
27
28
    /**
29
     * Has many human resources.
30
     *
31
     * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
32
     */
33 1
    public function business()
34
    {
35 1
        return $this->belongsTo(Business::class);
36
    }
37
38
    /**
39
     * Set Calendar link.
40
     *
41
     * @param string $calendar_link
42
     */
43
    public function setCalendarLinkAttribute($calendar_link)
44
    {
45
        return $this->attributes['calendar_link'] = trim($calendar_link) ?: null;
46
    }
47
48
    /**
49
     * TODO: Check slug setting can be moved to a more proper place.
50
     *
51
     * Save the model to the database.
52
     *
53
     * @param array $options
54
     *
55
     * @return bool
56
     */
57 4
    public function save(array $options = [])
58
    {
59 4
        $this->attributes['slug'] = str_slug($this->attributes['name']);
60
61 4
        return parent::save($options);
62
    }
63
}
64