ServiceType   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 52
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 3
c 0
b 0
f 0
lcom 1
cbo 1
dl 0
loc 52
ccs 7
cts 7
cp 1
rs 10

3 Methods

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