| @@ 14-93 (lines=80) @@ | ||
| 11 | * @author Ryan Thompson <[email protected]> |
|
| 12 | * @package Anomaly\Streams\Platform\Assignment |
|
| 13 | */ |
|
| 14 | class AssignmentPresenter extends EloquentPresenter |
|
| 15 | { |
|
| 16 | ||
| 17 | /** |
|
| 18 | * The decorated object. |
|
| 19 | * This is for IDE support. |
|
| 20 | * |
|
| 21 | * @var AssignmentInterface |
|
| 22 | */ |
|
| 23 | protected $object; |
|
| 24 | ||
| 25 | /** |
|
| 26 | * Return the flag labels. |
|
| 27 | * |
|
| 28 | * @param string $size |
|
| 29 | * @return string |
|
| 30 | */ |
|
| 31 | public function labels($size = 'sm') |
|
| 32 | { |
|
| 33 | return implode( |
|
| 34 | ' ', |
|
| 35 | [ |
|
| 36 | $this->requiredLabel($size), |
|
| 37 | $this->uniqueLabel($size), |
|
| 38 | $this->translatableLabel($size) |
|
| 39 | ] |
|
| 40 | ); |
|
| 41 | } |
|
| 42 | ||
| 43 | /** |
|
| 44 | * Return the required label. |
|
| 45 | * |
|
| 46 | * @param string $size |
|
| 47 | * @return null|string |
|
| 48 | */ |
|
| 49 | protected function requiredLabel($size = 'sm') |
|
| 50 | { |
|
| 51 | if ($this->object->isRequired()) { |
|
| 52 | return '<span class="label label-danger label-' . $size . '">' . trans( |
|
| 53 | 'streams::assignment.required.name' |
|
| 54 | ) . '</span>'; |
|
| 55 | } |
|
| 56 | ||
| 57 | return null; |
|
| 58 | } |
|
| 59 | ||
| 60 | /** |
|
| 61 | * Return the unique label. |
|
| 62 | * |
|
| 63 | * @param string $size |
|
| 64 | * @return null|string |
|
| 65 | */ |
|
| 66 | protected function uniqueLabel($size = 'sm') |
|
| 67 | { |
|
| 68 | if ($this->object->isUnique()) { |
|
| 69 | return '<span class="label label-primary label-' . $size . '">' . trans( |
|
| 70 | 'streams::assignment.unique.name' |
|
| 71 | ) . '</span>'; |
|
| 72 | } |
|
| 73 | ||
| 74 | return null; |
|
| 75 | } |
|
| 76 | ||
| 77 | /** |
|
| 78 | * Return the translatable label. |
|
| 79 | * |
|
| 80 | * @param string $size |
|
| 81 | * @return null|string |
|
| 82 | */ |
|
| 83 | protected function translatableLabel($size = 'sm') |
|
| 84 | { |
|
| 85 | if ($this->object->isTranslatable()) { |
|
| 86 | return '<span class="label label-info label-' . $size . '">' . trans( |
|
| 87 | 'streams::assignment.translatable.name' |
|
| 88 | ) . '</span>'; |
|
| 89 | } |
|
| 90 | ||
| 91 | return null; |
|
| 92 | } |
|
| 93 | } |
|
| 94 | ||
| @@ 14-93 (lines=80) @@ | ||
| 11 | * @author Ryan Thompson <[email protected]> |
|
| 12 | * @package Anomaly\Streams\Platform\Stream |
|
| 13 | */ |
|
| 14 | class StreamPresenter extends Presenter |
|
| 15 | { |
|
| 16 | ||
| 17 | /** |
|
| 18 | * The stream interface. |
|
| 19 | * |
|
| 20 | * @var StreamInterface |
|
| 21 | */ |
|
| 22 | protected $object; |
|
| 23 | ||
| 24 | /** |
|
| 25 | * Return the flag labels. |
|
| 26 | * |
|
| 27 | * @param string $size |
|
| 28 | * @return string |
|
| 29 | */ |
|
| 30 | public function labels($size = 'sm') |
|
| 31 | { |
|
| 32 | return implode( |
|
| 33 | ' ', |
|
| 34 | [ |
|
| 35 | $this->translatableLabel($size), |
|
| 36 | $this->trashableLabel($size), |
|
| 37 | $this->sortableLabel($size) |
|
| 38 | ] |
|
| 39 | ); |
|
| 40 | } |
|
| 41 | ||
| 42 | /** |
|
| 43 | * Return the translatable label. |
|
| 44 | * |
|
| 45 | * @param string $size |
|
| 46 | * @return null|string |
|
| 47 | */ |
|
| 48 | protected function translatableLabel($size = 'sm') |
|
| 49 | { |
|
| 50 | if ($this->object->isTranslatable()) { |
|
| 51 | return '<span class="label label-info label-' . $size . '">' . trans( |
|
| 52 | 'streams::field.translatable.name' |
|
| 53 | ) . '</span>'; |
|
| 54 | } |
|
| 55 | ||
| 56 | return null; |
|
| 57 | } |
|
| 58 | ||
| 59 | /** |
|
| 60 | * Return the trashable label. |
|
| 61 | * |
|
| 62 | * @param string $size |
|
| 63 | * @return null|string |
|
| 64 | */ |
|
| 65 | protected function trashableLabel($size = 'sm') |
|
| 66 | { |
|
| 67 | if ($this->object->isTrashable()) { |
|
| 68 | return '<span class="label label-danger label-' . $size . '">' . trans( |
|
| 69 | 'streams::field.trashable.name' |
|
| 70 | ) . '</span>'; |
|
| 71 | } |
|
| 72 | ||
| 73 | return null; |
|
| 74 | } |
|
| 75 | ||
| 76 | /** |
|
| 77 | * Return the sortable label. |
|
| 78 | * |
|
| 79 | * @param string $size |
|
| 80 | * @return null|string |
|
| 81 | */ |
|
| 82 | protected function sortableLabel($size = 'sm') |
|
| 83 | { |
|
| 84 | if ($this->object->isSortable()) { |
|
| 85 | return '<span class="label label-primary label-' . $size . '">' . trans( |
|
| 86 | 'streams::field.sortable.name' |
|
| 87 | ) . '</span>'; |
|
| 88 | } |
|
| 89 | ||
| 90 | return null; |
|
| 91 | } |
|
| 92 | ||
| 93 | } |
|
| 94 | ||