Page   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 56
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 1
dl 0
loc 56
rs 10
c 0
b 0
f 0
ccs 0
cts 6
cp 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A getExcerptAttribute() 0 6 2
1
<?php namespace Arcanesoft\Pages\Models;
2
3
use Arcanesoft\Pages\Bases\Model;
4
use Illuminate\Database\Eloquent\SoftDeletes;
5
6
/**
7
 * Class     Page
8
 *
9
 * @package  Arcanesoft\Pages\Models
10
 * @author   ARCANEDEV <[email protected]>
11
 *
12
 * @property  int             id
13
 * @property  int             author_id
14
 * @property  string          title
15
 * @property  string          slug
16
 * @property  string          content
17
 * @property  string          template
18
 * @property  \Carbon\Carbon  created_at
19
 * @property  \Carbon\Carbon  updated_at
20
 * @property  \Carbon\Carbon  deleted_at
21
 */
22
class Page extends Model
23
{
24
    /* ------------------------------------------------------------------------------------------------
25
     |  Trait
26
     | ------------------------------------------------------------------------------------------------
27
     */
28
    use SoftDeletes;
29
30
    /* ------------------------------------------------------------------------------------------------
31
     |  Properties
32
     | ------------------------------------------------------------------------------------------------
33
     */
34
    /**
35
     * The table associated with the model.
36
     *
37
     * @var string
38
     */
39
    protected $table = 'pages';
40
41
    /**
42
     * The attributes that are mass assignable.
43
     *
44
     * @var array
45
     */
46
    protected $fillable = ['title', 'slug', 'body', 'active', 'parent_id'];
47
48
    /**
49
     * The accessors to append to the model's array form.
50
     *
51
     * @var array
52
     */
53
    protected $appends = ['excerpt'];
54
55
    /**
56
     * The attributes that should be mutated to dates.
57
     *
58
     * @var array
59
     */
60
    protected $dates = ['deleted_at'];
61
62
    /* ------------------------------------------------------------------------------------------------
63
     |  Getters & Setters
64
     | ------------------------------------------------------------------------------------------------
65
     */
66
    /**
67
     * The pages short content.
68
     *
69
     * @return null|string
70
     */
71
    public function getExcerptAttribute()
72
    {
73
        return array_key_exists('body', $this->attributes)
74
            ? str_limit(strip_tags($this->attributes['body']), 200)
75
            : null;
76
    }
77
}
78