1 | <?php namespace Arcanesoft\Blog\Models; |
||
20 | class Category extends Model |
||
21 | { |
||
22 | /* ------------------------------------------------------------------------------------------------ |
||
23 | | Traits |
||
24 | | ------------------------------------------------------------------------------------------------ |
||
25 | */ |
||
26 | use SoftDeletes; |
||
27 | |||
28 | /* ------------------------------------------------------------------------------------------------ |
||
29 | | Properties |
||
30 | | ------------------------------------------------------------------------------------------------ |
||
31 | */ |
||
32 | /** |
||
33 | * The database table used by the model |
||
34 | * |
||
35 | * @var string |
||
36 | */ |
||
37 | protected $table = 'categories'; |
||
38 | |||
39 | /** |
||
40 | * The attributes that are mass assignable |
||
41 | * |
||
42 | * @var array |
||
43 | */ |
||
44 | protected $fillable = ['name']; |
||
45 | |||
46 | /** |
||
47 | * Set or unset the timestamps for the model |
||
48 | * |
||
49 | * @var bool |
||
50 | */ |
||
51 | public $timestamps = true; |
||
52 | |||
53 | /** |
||
54 | * The attributes that should be mutated to dates. |
||
55 | * |
||
56 | * @var array |
||
57 | */ |
||
58 | protected $dates = ['deleted_at']; |
||
59 | |||
60 | /* ------------------------------------------------------------------------------------------------ |
||
61 | | Relationships |
||
62 | | ------------------------------------------------------------------------------------------------ |
||
63 | */ |
||
64 | /** |
||
65 | * Relationship with posts. |
||
66 | * |
||
67 | * @return \Illuminate\Database\Eloquent\Relations\HasMany |
||
68 | */ |
||
69 | public function posts() |
||
73 | |||
74 | /* ------------------------------------------------------------------------------------------------ |
||
75 | | Getters & Setters |
||
76 | | ------------------------------------------------------------------------------------------------ |
||
77 | */ |
||
78 | /** |
||
79 | * Set the name attribute. |
||
80 | * |
||
81 | * @param string $name |
||
82 | */ |
||
83 | public function setNameAttribute($name) |
||
88 | |||
89 | /* ------------------------------------------------------------------------------------------------ |
||
90 | | Main Functions |
||
91 | | ------------------------------------------------------------------------------------------------ |
||
92 | */ |
||
93 | /** |
||
94 | * Get the categories options for select input. |
||
95 | * |
||
96 | * @return array |
||
97 | */ |
||
98 | public static function getSelectOptions($placehoder = true) |
||
107 | } |
||
108 |