Tag   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 41
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2
Metric Value
wmc 2
lcom 0
cbo 2
dl 0
loc 41
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A boot() 0 8 1
A projects() 0 4 1
1
<?php
2
3
/*
4
 * This file is part of Gitamin.
5
 *
6
 * Copyright (C) 2015-2016 The Gitamin Team
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Gitamin\Models;
13
14
use Illuminate\Database\Eloquent\Model;
15
use Illuminate\Support\Str;
16
17
class Tag extends Model
18
{
19
    /**
20
     * The attributes that should be casted to native types.
21
     *
22
     * @var string[]
23
     */
24
    protected $casts = [
25
        'id' => 'int',
26
        'name' => 'string',
27
    ];
28
29
    /**
30
     * The fillable properties.
31
     *
32
     * @var string[]
33
     */
34
    protected $fillable = ['name'];
35
36
    /**
37
     * Overrides the models boot method.
38
     */
39
    public static function boot()
40
    {
41
        parent::boot();
42
43
        self::creating(function ($tag) {
44
            $tag->slug = Str::slug($tag->name);
45
        });
46
    }
47
48
    /**
49
     * Tags can have many projects.
50
     *
51
     * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany
52
     */
53
    public function projects()
54
    {
55
        return $this->belongsToMany(Project::class);
56
    }
57
}
58