-
-
Notifications
You must be signed in to change notification settings - Fork 167
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 #160 from kellerjmrtn/add-support-for-blade-views
Add view() Method Which Renders HTML Via A Blade View
- Loading branch information
Showing
1 changed file
with
29 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,7 @@ | |
|
||
namespace RealRashid\SweetAlert; | ||
|
||
use Illuminate\Contracts\View\Factory as ViewFactory; | ||
use RealRashid\SweetAlert\Storage\SessionStore; | ||
|
||
class Toaster | ||
|
@@ -14,6 +15,14 @@ class Toaster | |
*/ | ||
protected $session; | ||
|
||
/** | ||
* View Factory. | ||
* | ||
* @var \Illuminate\Contracts\View\Factory | ||
* @author Keller Martin <[email protected]> | ||
*/ | ||
protected ViewFactory $view; | ||
|
||
/** | ||
* Configuration options. | ||
* | ||
|
@@ -26,12 +35,14 @@ class Toaster | |
* Setting up the session | ||
* | ||
* @param SessionStore $session | ||
* @param ViewFactory $view | ||
* @author Rashid Ali <[email protected]> | ||
*/ | ||
public function __construct(SessionStore $session) | ||
public function __construct(SessionStore $session, ViewFactory $view) | ||
{ | ||
$this->setDefaultConfig(); | ||
$this->session = $session; | ||
$this->view = $view; | ||
} | ||
|
||
/** | ||
|
@@ -274,6 +285,23 @@ public function html($title = '', $code = '', $icon = '') | |
return $this; | ||
} | ||
|
||
/** | ||
* Display an html typed alert message which is generated from a view | ||
* | ||
* @param string $title | ||
* @param string $view | ||
* @param array $data | ||
* @param array $mergeData | ||
* @param string $icon | ||
* @author Keller Martin <[email protected]> | ||
*/ | ||
public function view($title, $view, $data = [], $mergeData = [], $icon = '') | ||
{ | ||
$html = $this->view->make($view, $data, $mergeData)->render(); | ||
|
||
return $this->html($title, $html, $icon); | ||
} | ||
|
||
/** | ||
* Display a toast message | ||
* | ||
|