| @@ 8-30 (lines=23) @@ | ||
| 5 | use BeyondCode\TagHelper\Helper; |
|
| 6 | use BeyondCode\TagHelper\Html\HtmlElement; |
|
| 7 | ||
| 8 | class AuthHelper extends Helper |
|
| 9 | { |
|
| 10 | protected $targetAttribute = 'auth'; |
|
| 11 | ||
| 12 | public function process(HtmlElement $element) |
|
| 13 | { |
|
| 14 | // Check if an explicit attribute value was specified. |
|
| 15 | if ($element->getAttribute('auth') === true) { |
|
| 16 | $auth = null; |
|
| 17 | } else { |
|
| 18 | $auth = $element->getAttributeForBlade('auth'); |
|
| 19 | } |
|
| 20 | ||
| 21 | $element->removeAttribute('auth'); |
|
| 22 | ||
| 23 | $outerText = '@auth('.$auth.') '; |
|
| 24 | $outerText .= $element->getOuterText(); |
|
| 25 | $outerText .= ' @endauth'; |
|
| 26 | ||
| 27 | $element->setOuterText($outerText); |
|
| 28 | ||
| 29 | } |
|
| 30 | } |
|
| 31 | ||
| @@ 8-30 (lines=23) @@ | ||
| 5 | use BeyondCode\TagHelper\Helper; |
|
| 6 | use BeyondCode\TagHelper\Html\HtmlElement; |
|
| 7 | ||
| 8 | class GuestHelper extends Helper |
|
| 9 | { |
|
| 10 | protected $targetAttribute = 'guest'; |
|
| 11 | ||
| 12 | public function process(HtmlElement $element) |
|
| 13 | { |
|
| 14 | // Check if an explicit attribute value was specified. |
|
| 15 | if ($element->getAttribute('guest') === true) { |
|
| 16 | $guest = null; |
|
| 17 | } else { |
|
| 18 | $guest = $element->getAttributeForBlade('guest'); |
|
| 19 | } |
|
| 20 | ||
| 21 | $element->removeAttribute('guest'); |
|
| 22 | ||
| 23 | $outerText = '@guest('.$guest.') '; |
|
| 24 | $outerText .= $element->getOuterText(); |
|
| 25 | $outerText .= ' @endguest'; |
|
| 26 | ||
| 27 | $element->setOuterText($outerText); |
|
| 28 | ||
| 29 | } |
|
| 30 | } |
|
| 31 | ||