1 | <?php namespace Arcanesoft\Blog\Models; |
||
12 | class Category extends AbstractTaxonomy |
||
13 | { |
||
14 | /* ----------------------------------------------------------------- |
||
15 | | Constants |
||
16 | | ----------------------------------------------------------------- |
||
17 | */ |
||
18 | |||
19 | const SELECT_CACHE_NAME = 'blog::categories.select-data'; |
||
20 | |||
21 | /* ----------------------------------------------------------------- |
||
22 | | Properties |
||
23 | | ----------------------------------------------------------------- |
||
24 | */ |
||
25 | |||
26 | /** |
||
27 | * The database table used by the model |
||
28 | * |
||
29 | * @var string |
||
30 | */ |
||
31 | protected $table = 'categories'; |
||
32 | |||
33 | /** |
||
34 | * The event map for the model. |
||
35 | * |
||
36 | * @var array |
||
37 | */ |
||
38 | protected $dispatchesEvents = [ |
||
39 | 'creating' => CategoryEvents\CategoryCreating::class, |
||
40 | 'created' => CategoryEvents\CategoryCreated::class, |
||
41 | 'updating' => CategoryEvents\CategoryUpdating::class, |
||
42 | 'updated' => CategoryEvents\CategoryUpdated::class, |
||
43 | 'saving' => CategoryEvents\CategorySaving::class, |
||
44 | 'saved' => CategoryEvents\CategorySaved::class, |
||
45 | 'deleting' => CategoryEvents\CategoryDeleting::class, |
||
46 | 'deleted' => CategoryEvents\CategoryDeleted::class, |
||
47 | 'restoring' => CategoryEvents\CategoryRestoring::class, |
||
48 | 'restored' => CategoryEvents\CategoryRestored::class, |
||
49 | ]; |
||
50 | |||
51 | /* ----------------------------------------------------------------- |
||
52 | | Relationships |
||
53 | | ----------------------------------------------------------------- |
||
54 | */ |
||
55 | |||
56 | /** |
||
57 | * Relationship with posts. |
||
58 | * |
||
59 | * @return \Illuminate\Database\Eloquent\Relations\HasMany |
||
60 | */ |
||
61 | 3 | public function posts() |
|
65 | |||
66 | /* ----------------------------------------------------------------- |
||
67 | | Main Methods |
||
68 | | ----------------------------------------------------------------- |
||
69 | */ |
||
70 | |||
71 | /** |
||
72 | * Get the categories options for select input. |
||
73 | * |
||
74 | * @param bool $placeholder |
||
75 | * |
||
76 | * @return \Illuminate\Support\Collection |
||
77 | */ |
||
78 | 3 | public static function getSelectData($placeholder = true) |
|
99 | } |
||
100 |