-
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: crynobone <crynobone@gmail.com>
- Loading branch information
Showing
5 changed files
with
121 additions
and
135 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 |
---|---|---|
@@ -1,55 +1,47 @@ | ||
Using Messages | ||
============== | ||
--- | ||
title: Using Messages | ||
--- | ||
|
||
`Orchestra\Messages` utilize `Illuminate\Support\MessageBag` to bring notification support through-out Orchestra Platform (and Laravel 4). | ||
|
||
## Adding a Message | ||
* [Adding a Message](#add-message) | ||
* [Extending a Message to Current Response](#extend-for-current-request) | ||
* [Displaying the Message in a View](#displaying-message) | ||
|
||
## Adding a Message {#add-message} | ||
|
||
Adding a message is as easy as following: | ||
|
||
```php | ||
Orchestra\Messages::add('success', 'A successful message'); | ||
``` | ||
Orchestra\Messages::add('success', 'A successful message'); | ||
|
||
You can also chain messages: | ||
|
||
```php | ||
Orchestra\Messages::add('success', 'A successful message') | ||
->add('error', 'Some error'); | ||
``` | ||
</article> | ||
Orchestra\Messages::add('success', 'A successful message') | ||
->add('error', 'Some error'); | ||
|
||
## Extending a Message to Current Response | ||
## Extending a Message to Current Response {#extend-for-current-request} | ||
|
||
There might be situation where you need to extend a message to the current response instead of the following request. You can do this with: | ||
|
||
```php | ||
Orchestra\Messages::extend(function ($message) | ||
{ | ||
$message->add('info', 'Read-only mode'); | ||
}); | ||
``` | ||
Orchestra\Messages::extend(function ($message) { | ||
$message->add('info', 'Read-only mode'); | ||
}); | ||
|
||
## Displaying the Message in a View | ||
## Displaying the Message in a View {#displaying-message} | ||
|
||
Here's an example how you can display the message: | ||
|
||
```php | ||
<?php | ||
|
||
$message = Orchestra\Messages::retrieve(); | ||
|
||
if ($message instanceof Orchestra\Support\Messages) | ||
{ | ||
foreach (['error', 'info', 'success'] as $key) | ||
{ | ||
if ($message->has($key)) | ||
{ | ||
$message->setFormat( | ||
'<div class="alert alert-'.$key.'">:message</div>' | ||
); | ||
echo implode('', $message->get($key)); | ||
<?php | ||
$message = Orchestra\Messages::retrieve(); | ||
if ($message instanceof Orchestra\Support\Messages) { | ||
foreach (['error', 'info', 'success'] as $key) { | ||
if ($message->has($key)) { | ||
$message->setFormat( | ||
'<div class="alert alert-'.$key.'">:message</div>' | ||
); | ||
echo implode('', $message->get($key)); | ||
} | ||
} | ||
} | ||
} | ||
``` |
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 |
---|---|---|
@@ -1,29 +1,27 @@ | ||
String Helper Class | ||
============== | ||
--- | ||
title: String Helper Class | ||
--- | ||
|
||
`Orchestra\Support\Str` is probably one of the few internal API class that you might use directly. It extends `Illuminate\Support\Str` and offer some improvement. | ||
|
||
* [Title](#title) | ||
* [Title](#str-title) | ||
* [Stream Get Contents](#stream-get-contents) | ||
|
||
## Title | ||
## Title {#str-title} | ||
|
||
Allow a string to be transformed to a proper title. | ||
|
||
```php | ||
use Orchestra\Support\Str; | ||
use Orchestra\Support\Str; | ||
|
||
return Str::title('hello-world'); // would return "Hello World" | ||
``` | ||
return Str::title('hello-world'); // would return "Hello World" | ||
|
||
## Stream Get Contents | ||
## Stream Get Contents {#stream-get-contents} | ||
|
||
Unliked other database driver, when using blob with PostgreSQL, the return value from database is a stream instead of string, using above helper method help convert it properly back to string. | ||
|
||
```php | ||
use Orchestra\Support\Str; | ||
use Orchestra\Support\Str; | ||
|
||
$str = Str::streamGetContents($blob); | ||
|
||
$str = Str::streamGetContents($blob); | ||
``` | ||
|
||
> The method would return original string when it detect that it isn't a stream. |