-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #9 from andela-sachungo/develop
Added alerts
- Loading branch information
Showing
27 changed files
with
3,849 additions
and
263 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
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,60 @@ | ||
<?php | ||
|
||
namespace Soma\Http; | ||
|
||
class Flash | ||
{ | ||
/** | ||
* Create a flash message. | ||
* | ||
* @param string $title | ||
* @param string $message | ||
* @param string $key | ||
* @return void | ||
*/ | ||
public function createFlash($title, $message, $type, $key = 'flash_message') | ||
{ | ||
// Flash is HTTP specific hence no need to inject the Session::store() | ||
session()->flash($key, [ | ||
'title' => $title, | ||
'message' => $message, | ||
'type' => $type, | ||
]); | ||
} | ||
|
||
/** | ||
* Create an info flash message. | ||
* | ||
* @param string $title | ||
* @param string $message | ||
* @return void | ||
*/ | ||
public function info($title, $message) | ||
{ | ||
return $this->createFlash($title, $message, 'info'); | ||
} | ||
|
||
/** | ||
* Create a success flash message. | ||
* | ||
* @param string $title | ||
* @param string $message | ||
* @return void | ||
*/ | ||
public function success($title, $message) | ||
{ | ||
return $this->createFlash($title, $message, 'success'); | ||
} | ||
|
||
/** | ||
* Create an error flash message. | ||
* | ||
* @param string $title | ||
* @param string $message | ||
* @return void | ||
*/ | ||
public function error($title, $message) | ||
{ | ||
return $this->createFlash($title, $message, 'error'); | ||
} | ||
} |
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 +1,21 @@ | ||
<?php | ||
/** | ||
* A global helper function for creating flash messages using sweet alert. | ||
* | ||
* The app helper function grabs the Flash instance from the container. | ||
* If the flash() function is called with no arguments, return the other | ||
* methods in the Flash class, e.g., success(), else return the info | ||
* method. | ||
* | ||
* @return void | ||
*/ | ||
function flash($title = null, $message = null) | ||
{ | ||
$flash = app('Soma\Http\Flash'); | ||
|
||
if (func_num_args() == 0) { | ||
return $flash; | ||
} | ||
|
||
return $flash->info($title, $message); | ||
} |
Oops, something went wrong.