@@ -4,10 +4,10 @@ |
||
| 4 | 4 | |
| 5 | 5 | abstract class Component extends \Illuminate\View\Component |
| 6 | 6 | { |
| 7 | - protected static ?string $name = null; |
|
| 7 | + protected static ?string $name = null; |
|
| 8 | 8 | |
| 9 | - public static function getComponentName(): ?string |
|
| 10 | - { |
|
| 11 | - return static::$name; |
|
| 12 | - } |
|
| 9 | + public static function getComponentName(): ?string |
|
| 10 | + { |
|
| 11 | + return static::$name; |
|
| 12 | + } |
|
| 13 | 13 | } |
| 14 | 14 | \ No newline at end of file |
@@ -6,28 +6,28 @@ |
||
| 6 | 6 | |
| 7 | 7 | class CardWidget extends Component |
| 8 | 8 | { |
| 9 | - protected static ?string $name = 'card-widget'; |
|
| 10 | - public string $title; |
|
| 11 | - public string $description; |
|
| 9 | + protected static ?string $name = 'card-widget'; |
|
| 10 | + public string $title; |
|
| 11 | + public string $description; |
|
| 12 | 12 | |
| 13 | - public function __construct($title, $description) |
|
| 14 | - { |
|
| 15 | - $this->title = $title; |
|
| 16 | - $this->description = $description; |
|
| 17 | - } |
|
| 13 | + public function __construct($title, $description) |
|
| 14 | + { |
|
| 15 | + $this->title = $title; |
|
| 16 | + $this->description = $description; |
|
| 17 | + } |
|
| 18 | 18 | |
| 19 | - /** |
|
| 20 | - * @inheritDoc |
|
| 21 | - */ |
|
| 22 | - public function render(): string |
|
| 23 | - { |
|
| 24 | - return view( |
|
| 25 | - sprintf( |
|
| 26 | - '%s::%s', |
|
| 27 | - CoreServiceProvider::VIEWS_NAMESPACE, |
|
| 28 | - 'elements.widgets.simple-card' |
|
| 29 | - ) |
|
| 30 | - ) |
|
| 31 | - ->render(); |
|
| 32 | - } |
|
| 19 | + /** |
|
| 20 | + * @inheritDoc |
|
| 21 | + */ |
|
| 22 | + public function render(): string |
|
| 23 | + { |
|
| 24 | + return view( |
|
| 25 | + sprintf( |
|
| 26 | + '%s::%s', |
|
| 27 | + CoreServiceProvider::VIEWS_NAMESPACE, |
|
| 28 | + 'elements.widgets.simple-card' |
|
| 29 | + ) |
|
| 30 | + ) |
|
| 31 | + ->render(); |
|
| 32 | + } |
|
| 33 | 33 | } |
@@ -10,81 +10,81 @@ |
||
| 10 | 10 | |
| 11 | 11 | class MaterialDashboardPro |
| 12 | 12 | { |
| 13 | - private Request $request; |
|
| 14 | - private array $menu = []; |
|
| 15 | - private string $pageTitle = 'Page'; |
|
| 16 | - private $user = null; |
|
| 17 | - |
|
| 18 | - private string $backgroundUrl = 'https://picsum.photos/2880/1920?blur=2'; |
|
| 19 | - |
|
| 20 | - /** |
|
| 21 | - * @param Request $request |
|
| 22 | - */ |
|
| 23 | - public function __construct(Request $request) |
|
| 24 | - { |
|
| 25 | - $this->request = $request; |
|
| 26 | - $this->setMenu(); |
|
| 27 | - $this->setUser($this->request->user()); |
|
| 28 | - $this->setBackgroundUrl(); |
|
| 29 | - } |
|
| 30 | - |
|
| 31 | - public function getRandomBackgroundUrl(): string |
|
| 32 | - { |
|
| 33 | - return $this->backgroundUrl; |
|
| 34 | - } |
|
| 35 | - |
|
| 36 | - /** |
|
| 37 | - * @return void |
|
| 38 | - */ |
|
| 39 | - private function setMenu(): void |
|
| 40 | - { |
|
| 41 | - /** @var MenuBuilder $menuBuilder */ |
|
| 42 | - $menuBuilder = resolve(MenuBuilder::class); |
|
| 43 | - $this->menu = $menuBuilder->build(); |
|
| 44 | - } |
|
| 45 | - |
|
| 46 | - /** |
|
| 47 | - * @param Model|null $user |
|
| 48 | - * @return $this |
|
| 49 | - */ |
|
| 50 | - private function setUser(?Model $user): static |
|
| 51 | - { |
|
| 52 | - $this->user = $user; |
|
| 53 | - |
|
| 54 | - return $this; |
|
| 55 | - } |
|
| 56 | - |
|
| 57 | - public function setBackgroundUrl(): static |
|
| 58 | - { |
|
| 59 | - $this->backgroundUrl = config('mdp.core.static.login_image', $this->backgroundUrl); |
|
| 60 | - |
|
| 61 | - return $this; |
|
| 62 | - } |
|
| 63 | - |
|
| 64 | - public function hasUser(string $guard = null) |
|
| 65 | - { |
|
| 66 | - return $this->request->user($guard) ?? false; |
|
| 67 | - } |
|
| 68 | - |
|
| 69 | - public function getUser() |
|
| 70 | - { |
|
| 71 | - return $this->user; |
|
| 72 | - } |
|
| 73 | - |
|
| 74 | - public function getPageTitle(): string |
|
| 75 | - { |
|
| 76 | - return $this->pageTitle; |
|
| 77 | - } |
|
| 78 | - |
|
| 79 | - public function setPageTitle(string $pageTitle): static |
|
| 80 | - { |
|
| 81 | - $this->pageTitle = $pageTitle; |
|
| 82 | - |
|
| 83 | - return $this; |
|
| 84 | - } |
|
| 85 | - |
|
| 86 | - public function getMenu(): array |
|
| 87 | - { |
|
| 88 | - return $this->menu; |
|
| 89 | - } |
|
| 13 | + private Request $request; |
|
| 14 | + private array $menu = []; |
|
| 15 | + private string $pageTitle = 'Page'; |
|
| 16 | + private $user = null; |
|
| 17 | + |
|
| 18 | + private string $backgroundUrl = 'https://picsum.photos/2880/1920?blur=2'; |
|
| 19 | + |
|
| 20 | + /** |
|
| 21 | + * @param Request $request |
|
| 22 | + */ |
|
| 23 | + public function __construct(Request $request) |
|
| 24 | + { |
|
| 25 | + $this->request = $request; |
|
| 26 | + $this->setMenu(); |
|
| 27 | + $this->setUser($this->request->user()); |
|
| 28 | + $this->setBackgroundUrl(); |
|
| 29 | + } |
|
| 30 | + |
|
| 31 | + public function getRandomBackgroundUrl(): string |
|
| 32 | + { |
|
| 33 | + return $this->backgroundUrl; |
|
| 34 | + } |
|
| 35 | + |
|
| 36 | + /** |
|
| 37 | + * @return void |
|
| 38 | + */ |
|
| 39 | + private function setMenu(): void |
|
| 40 | + { |
|
| 41 | + /** @var MenuBuilder $menuBuilder */ |
|
| 42 | + $menuBuilder = resolve(MenuBuilder::class); |
|
| 43 | + $this->menu = $menuBuilder->build(); |
|
| 44 | + } |
|
| 45 | + |
|
| 46 | + /** |
|
| 47 | + * @param Model|null $user |
|
| 48 | + * @return $this |
|
| 49 | + */ |
|
| 50 | + private function setUser(?Model $user): static |
|
| 51 | + { |
|
| 52 | + $this->user = $user; |
|
| 53 | + |
|
| 54 | + return $this; |
|
| 55 | + } |
|
| 56 | + |
|
| 57 | + public function setBackgroundUrl(): static |
|
| 58 | + { |
|
| 59 | + $this->backgroundUrl = config('mdp.core.static.login_image', $this->backgroundUrl); |
|
| 60 | + |
|
| 61 | + return $this; |
|
| 62 | + } |
|
| 63 | + |
|
| 64 | + public function hasUser(string $guard = null) |
|
| 65 | + { |
|
| 66 | + return $this->request->user($guard) ?? false; |
|
| 67 | + } |
|
| 68 | + |
|
| 69 | + public function getUser() |
|
| 70 | + { |
|
| 71 | + return $this->user; |
|
| 72 | + } |
|
| 73 | + |
|
| 74 | + public function getPageTitle(): string |
|
| 75 | + { |
|
| 76 | + return $this->pageTitle; |
|
| 77 | + } |
|
| 78 | + |
|
| 79 | + public function setPageTitle(string $pageTitle): static |
|
| 80 | + { |
|
| 81 | + $this->pageTitle = $pageTitle; |
|
| 82 | + |
|
| 83 | + return $this; |
|
| 84 | + } |
|
| 85 | + |
|
| 86 | + public function getMenu(): array |
|
| 87 | + { |
|
| 88 | + return $this->menu; |
|
| 89 | + } |
|
| 90 | 90 | } |