Theme   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 71
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 21
c 1
b 0
f 0
dl 0
loc 71
rs 10
wmc 4

2 Methods

Rating   Name   Duplication   Size   Complexity  
A rules() 0 10 3
A profile() 0 3 1
1
<?php
2
3
namespace App\Models;
4
5
use Illuminate\Database\Eloquent\Model;
6
use Illuminate\Database\Eloquent\SoftDeletes;
7
8
class Theme extends Model
9
{
10
    use SoftDeletes;
11
12
    /**
13
     * The database table used by the model.
14
     *
15
     * @var string
16
     */
17
    protected $table = 'themes';
18
19
    /**
20
     * The attributes that are not mass assignable.
21
     *
22
     * @var array
23
     */
24
    protected $guarded = [
25
        'id',
26
    ];
27
28
    /**
29
     * Fillable fields for a Profile.
30
     *
31
     * @var array
32
     */
33
    protected $fillable = [
34
        'name',
35
        'link',
36
        'notes',
37
        'status',
38
        'taggable_id',
39
        'taggable_type',
40
    ];
41
42
    /**
43
     * The attributes that should be mutated to dates.
44
     *
45
     * @var array
46
     */
47
    protected $dates = [
48
        'deleted_at',
49
    ];
50
51
    /**
52
     * Get a validator for an incoming registration request.
53
     *
54
     * @param array $data
55
     *
56
     * @return array
57
     */
58
    public static function rules($id = 0, $merge = [])
59
    {
60
        return array_merge(
61
            [
62
                'name'   => 'required|min:3|max:50|unique:themes,name'.($id ? ",$id" : ''),
63
                'link'   => 'required|min:3|max:255|unique:themes,link'.($id ? ",$id" : ''),
64
                'notes'  => 'max:500',
65
                'status' => 'required',
66
            ],
67
            $merge
68
        );
69
    }
70
71
    /**
72
     * Build Theme Relationships.
73
     *
74
     * @var array
75
     */
76
    public function profile()
77
    {
78
        return $this->hasMany('App\Models\Profile');
79
    }
80
}
81