| @@ 6-57 (lines=52) @@ | ||
| 3 | use Modules\Blog\Repositories\CategoryRepository; |
|
| 4 | use Modules\Dashboard\Foundation\Widgets\BaseWidget; |
|
| 5 | ||
| 6 | class CategoriesWidget extends BaseWidget |
|
| 7 | { |
|
| 8 | /** |
|
| 9 | * @var CategoryRepository |
|
| 10 | */ |
|
| 11 | private $category; |
|
| 12 | ||
| 13 | public function __construct(CategoryRepository $category) |
|
| 14 | { |
|
| 15 | $this->category = $category; |
|
| 16 | } |
|
| 17 | ||
| 18 | /** |
|
| 19 | * Get the widget name |
|
| 20 | * @return string |
|
| 21 | */ |
|
| 22 | protected function name() |
|
| 23 | { |
|
| 24 | return 'CategoriesWidget'; |
|
| 25 | } |
|
| 26 | ||
| 27 | /** |
|
| 28 | * Get the widget view |
|
| 29 | * @return string |
|
| 30 | */ |
|
| 31 | protected function view() |
|
| 32 | { |
|
| 33 | return 'blog::admin.widgets.categories'; |
|
| 34 | } |
|
| 35 | ||
| 36 | /** |
|
| 37 | * Get the widget data to send to the view |
|
| 38 | * @return string |
|
| 39 | */ |
|
| 40 | protected function data() |
|
| 41 | { |
|
| 42 | return ['categoryCount' => $this->category->all()->count()]; |
|
| 43 | } |
|
| 44 | ||
| 45 | /** |
|
| 46 | * Get the widget type |
|
| 47 | * @return string |
|
| 48 | */ |
|
| 49 | protected function options() |
|
| 50 | { |
|
| 51 | return [ |
|
| 52 | 'width' => '2', |
|
| 53 | 'height' => '2', |
|
| 54 | 'x' => '2', |
|
| 55 | ]; |
|
| 56 | } |
|
| 57 | } |
|
| 58 | ||
| @@ 6-57 (lines=52) @@ | ||
| 3 | use Modules\Blog\Repositories\PostRepository; |
|
| 4 | use Modules\Dashboard\Foundation\Widgets\BaseWidget; |
|
| 5 | ||
| 6 | class PostsWidget extends BaseWidget |
|
| 7 | { |
|
| 8 | /** |
|
| 9 | * @var \Modules\Blog\Repositories\PostRepository |
|
| 10 | */ |
|
| 11 | private $post; |
|
| 12 | ||
| 13 | public function __construct(PostRepository $post) |
|
| 14 | { |
|
| 15 | $this->post = $post; |
|
| 16 | } |
|
| 17 | ||
| 18 | /** |
|
| 19 | * Get the widget name |
|
| 20 | * @return string |
|
| 21 | */ |
|
| 22 | protected function name() |
|
| 23 | { |
|
| 24 | return 'PostsWidget'; |
|
| 25 | } |
|
| 26 | ||
| 27 | /** |
|
| 28 | * Get the widget view |
|
| 29 | * @return string |
|
| 30 | */ |
|
| 31 | protected function view() |
|
| 32 | { |
|
| 33 | return 'blog::admin.widgets.posts'; |
|
| 34 | } |
|
| 35 | ||
| 36 | /** |
|
| 37 | * Get the widget data to send to the view |
|
| 38 | * @return string |
|
| 39 | */ |
|
| 40 | protected function data() |
|
| 41 | { |
|
| 42 | return ['postCount' => $this->post->all()->count()]; |
|
| 43 | } |
|
| 44 | ||
| 45 | /** |
|
| 46 | * Get the widget type |
|
| 47 | * @return string |
|
| 48 | */ |
|
| 49 | protected function options() |
|
| 50 | { |
|
| 51 | return [ |
|
| 52 | 'width' => '2', |
|
| 53 | 'height' => '2', |
|
| 54 | 'x' => '0', |
|
| 55 | ]; |
|
| 56 | } |
|
| 57 | } |
|
| 58 | ||