1 | <?php namespace jlourenco\blog\Models; |
||
10 | class BlogPost extends Model |
||
11 | { |
||
12 | |||
13 | /** |
||
14 | * To allow user actions identity (Created_by, Updated_by, Deleted_by) |
||
15 | */ |
||
16 | use Creation; |
||
17 | |||
18 | use Sluggable; |
||
19 | |||
20 | use SoftDeletes; |
||
21 | |||
22 | use Commentable; |
||
23 | |||
24 | /** |
||
25 | * {@inheritDoc} |
||
26 | */ |
||
27 | protected $table = 'BlogPost'; |
||
28 | |||
29 | /** |
||
30 | * The User model name. |
||
31 | * |
||
32 | * @var string |
||
33 | */ |
||
34 | protected static $usersModel = 'jlourenco\base\Models\BaseUser'; |
||
35 | |||
36 | /** |
||
37 | * The Blog category model name. |
||
38 | * |
||
39 | * @var string |
||
40 | */ |
||
41 | protected static $categoryModel = 'jlourenco\blog\Models\BlogCategory'; |
||
42 | |||
43 | protected $dates = [ 'created_at', 'deleted_at']; |
||
44 | |||
45 | /** |
||
46 | * {@inheritDoc} |
||
47 | */ |
||
48 | protected $fillable = [ |
||
49 | 'title', |
||
50 | 'slug', |
||
51 | 'contents', |
||
52 | 'category', |
||
53 | 'author', |
||
54 | 'likes', |
||
55 | 'shares', |
||
56 | 'views', |
||
57 | 'keywords' |
||
58 | ]; |
||
59 | |||
60 | /** |
||
61 | * Returns the user model. |
||
62 | * |
||
63 | * @return string |
||
64 | */ |
||
65 | public static function getUsersModel() |
||
69 | |||
70 | /** |
||
71 | * Sets the user model. |
||
72 | * |
||
73 | * @param string $usersModel |
||
74 | * @return void |
||
75 | */ |
||
76 | public static function setUsersModel($usersModel) |
||
80 | |||
81 | /** |
||
82 | * Returns the category model. |
||
83 | * |
||
84 | * @return string |
||
85 | */ |
||
86 | public static function getCategoriesModel() |
||
90 | |||
91 | /** |
||
92 | * Sets the categories model. |
||
93 | * |
||
94 | * @param string $categoryModel |
||
95 | * @return void |
||
96 | */ |
||
97 | public static function setCategoriesModel($categoryModel) |
||
101 | |||
102 | public function getAuthor() |
||
106 | |||
107 | public function getCategory() |
||
111 | |||
112 | /** |
||
113 | * Get the user's first name. |
||
114 | * |
||
115 | * @param string $value |
||
116 | * @return string |
||
117 | */ |
||
118 | public function getCreatedByAttribute($value) |
||
127 | |||
128 | |||
129 | } |
||
130 |