1 | <?php namespace Arcanesoft\Blog\Models; |
||
28 | class Post extends Model |
||
29 | { |
||
30 | /* ------------------------------------------------------------------------------------------------ |
||
31 | | Traits |
||
32 | | ------------------------------------------------------------------------------------------------ |
||
33 | */ |
||
34 | use SoftDeletes; |
||
35 | |||
36 | /* ------------------------------------------------------------------------------------------------ |
||
37 | | Properties |
||
38 | | ------------------------------------------------------------------------------------------------ |
||
39 | */ |
||
40 | /** |
||
41 | * The database table used by the model |
||
42 | * |
||
43 | * @var string |
||
44 | */ |
||
45 | protected $table = 'posts'; |
||
46 | |||
47 | /** |
||
48 | * The attributes that are mass assignable |
||
49 | * |
||
50 | * @var array |
||
51 | */ |
||
52 | protected $fillable = [ |
||
53 | 'user_id', 'category_id', 'title', 'excerpt', 'content', 'status', 'publish_date' |
||
54 | ]; |
||
55 | |||
56 | /** |
||
57 | * Set or unset the timestamps for the model |
||
58 | * |
||
59 | * @var bool |
||
60 | */ |
||
61 | public $timestamps = true; |
||
62 | |||
63 | /** |
||
64 | * The attributes that should be mutated to dates. |
||
65 | * |
||
66 | * @var array |
||
67 | */ |
||
68 | protected $dates = ['publish_date', 'deleted_at']; |
||
69 | |||
70 | /* ------------------------------------------------------------------------------------------------ |
||
71 | | Relationships |
||
72 | | ------------------------------------------------------------------------------------------------ |
||
73 | */ |
||
74 | /** |
||
75 | * Relationship with category. |
||
76 | * |
||
77 | * @return \Illuminate\Database\Eloquent\Relations\HasMany |
||
78 | */ |
||
79 | public function category() |
||
83 | |||
84 | /** |
||
85 | * Relationship with tags. |
||
86 | * |
||
87 | * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany |
||
88 | */ |
||
89 | public function tags() |
||
93 | |||
94 | /* ------------------------------------------------------------------------------------------------ |
||
95 | | Getters & Setters |
||
96 | | ------------------------------------------------------------------------------------------------ |
||
97 | */ |
||
98 | /** |
||
99 | * Set the title attribute. |
||
100 | * |
||
101 | * @param string $title |
||
102 | */ |
||
103 | public function setTitleAttribute($title) |
||
108 | } |
||
109 |