-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create alerts and make a alert for missing storage symlink show on da…
…shboard.
- Loading branch information
1 parent
39f4371
commit 8d50666
Showing
10 changed files
with
209 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
<?php | ||
|
||
namespace TCG\Voyager; | ||
|
||
use TCG\Voyager\Alert\Components\ComponentInterface; | ||
|
||
class Alert | ||
{ | ||
protected $components; | ||
|
||
protected $name; | ||
protected $type; | ||
|
||
public function __construct($name, $type = 'default') | ||
{ | ||
$this->name = $name; | ||
$this->type = $type; | ||
} | ||
|
||
public function addComponent(ComponentInterface $component) | ||
{ | ||
$this->components[] = $component; | ||
|
||
return $this; | ||
} | ||
|
||
public function __get($name) | ||
{ | ||
return $this->$name; | ||
} | ||
|
||
public function __call($name, $arguments) | ||
{ | ||
$component = app('voyager.alert.components.'.$name, ['alert' => $this]) | ||
->setAlert($this); | ||
|
||
call_user_func_array([$component, 'create'], $arguments); | ||
|
||
return $this->addComponent($component); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<?php | ||
|
||
namespace TCG\Voyager\Alert\Components; | ||
|
||
use TCG\Voyager\Alert; | ||
|
||
abstract class AbstractComponent implements ComponentInterface | ||
{ | ||
protected $alert; | ||
|
||
public function setAlert(Alert $alert) | ||
{ | ||
$this->alert = $alert; | ||
|
||
return $this; | ||
} | ||
|
||
public function __call($name, $arguments) | ||
{ | ||
return call_user_func_array([$this->alert, $name], $arguments); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<?php | ||
|
||
namespace TCG\Voyager\Alert\Components; | ||
|
||
class ButtonComponent extends AbstractComponent | ||
{ | ||
protected $text; | ||
protected $link; | ||
protected $style; | ||
|
||
public function create($text, $link = '#', $style = 'default') | ||
{ | ||
$this->text = $text; | ||
$this->link = $link; | ||
$this->style = $style; | ||
} | ||
|
||
public function render() | ||
{ | ||
return "<a href='{$this->link}' class='btn btn-{$this->style}'>{$this->text}</a>"; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<?php | ||
|
||
namespace TCG\Voyager\Alert\Components; | ||
|
||
interface ComponentInterface | ||
{ | ||
public function render(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<?php | ||
|
||
namespace TCG\Voyager\Alert\Components; | ||
|
||
class TextComponent extends AbstractComponent | ||
{ | ||
protected $text; | ||
|
||
public function create($text) | ||
{ | ||
$this->text = $text; | ||
} | ||
|
||
public function render() | ||
{ | ||
return "<p>{$this->text}</p>"; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<?php | ||
|
||
namespace TCG\Voyager\Alert\Components; | ||
|
||
class TitleComponent extends AbstractComponent | ||
{ | ||
protected $title; | ||
|
||
public function create($title) | ||
{ | ||
$this->title = $title; | ||
} | ||
|
||
public function render() | ||
{ | ||
return "<strong>{$this->title}</strong>"; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters