| @@ 8-45 (lines=38) @@ | ||
| 5 | use Microboard\Foundations\Widget; |
|
| 6 | use Microboard\Models\Role; |
|
| 7 | ||
| 8 | class DefaultRole extends Widget |
|
| 9 | { |
|
| 10 | /** |
|
| 11 | * The configuration array. |
|
| 12 | * |
|
| 13 | * @var array |
|
| 14 | */ |
|
| 15 | protected $config = [ |
|
| 16 | 'background' => 'bg-white', |
|
| 17 | 'icon-background' => 'primary', |
|
| 18 | 'text' => 'dark' |
|
| 19 | ]; |
|
| 20 | ||
| 21 | /** |
|
| 22 | * Treat this method as a controller action. |
|
| 23 | * Return view() or other content to display. |
|
| 24 | */ |
|
| 25 | public function run() |
|
| 26 | { |
|
| 27 | return view('microboard::state', [ |
|
| 28 | 'config' => $this->config, |
|
| 29 | 'title' => trans('microboard::pages.widgets.default-role.title'), |
|
| 30 | 'info' => trans('microboard::pages.widgets.default-role.info'), |
|
| 31 | 'icon' => 'ni ni-key-25', |
|
| 32 | 'count' => Role::where('name', config('microboard.roles.default', 'admin'))->first()->display_name |
|
| 33 | ]); |
|
| 34 | } |
|
| 35 | ||
| 36 | /** |
|
| 37 | * Determine if the widget should be displayed. |
|
| 38 | * |
|
| 39 | * @return bool |
|
| 40 | */ |
|
| 41 | public function shouldBeDisplayed() |
|
| 42 | { |
|
| 43 | return auth()->user()->can('viewAny', new Role); |
|
| 44 | } |
|
| 45 | } |
|
| 46 | ||
| @@ 8-45 (lines=38) @@ | ||
| 5 | use Microboard\Foundations\Widget; |
|
| 6 | use Microboard\Models\Role; |
|
| 7 | ||
| 8 | class PopularRole extends Widget |
|
| 9 | { |
|
| 10 | /** |
|
| 11 | * The configuration array. |
|
| 12 | * |
|
| 13 | * @var array |
|
| 14 | */ |
|
| 15 | protected $config = [ |
|
| 16 | 'background' => 'bg-white', |
|
| 17 | 'icon-background' => 'info', |
|
| 18 | 'text' => 'dark' |
|
| 19 | ]; |
|
| 20 | ||
| 21 | /** |
|
| 22 | * Treat this method as a controller action. |
|
| 23 | * Return view() or other content to display. |
|
| 24 | */ |
|
| 25 | public function run() |
|
| 26 | { |
|
| 27 | return view('microboard::state', [ |
|
| 28 | 'config' => $this->config, |
|
| 29 | 'title' => trans('microboard::pages.widgets.popular-roles.title'), |
|
| 30 | 'info' => trans('microboard::pages.widgets.popular-roles.info'), |
|
| 31 | 'icon' => 'ni ni-key-25', |
|
| 32 | 'count' => Role::withCount('users')->orderBy('users_count', 'desc')->first()->display_name |
|
| 33 | ]); |
|
| 34 | } |
|
| 35 | ||
| 36 | /** |
|
| 37 | * Determine if the widget should be displayed. |
|
| 38 | * |
|
| 39 | * @return bool |
|
| 40 | */ |
|
| 41 | public function shouldBeDisplayed() |
|
| 42 | { |
|
| 43 | return auth()->user()->can('viewAny', new Role); |
|
| 44 | } |
|
| 45 | } |
|
| 46 | ||