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
|
|
|
|