-
-
Save masterpowers/0a95cbe76002ff9b4906 to your computer and use it in GitHub Desktop.
LARAVEL: Displaying different module/package dashboard widgets using view composers.
This file contains hidden or 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
<!doctype html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<title>Laravel PHP Framework</title> | |
<style> | |
@import url(//fonts.googleapis.com/css?family=Lato:700); | |
body { | |
margin:0; | |
font-family:'Lato', sans-serif; | |
text-align:center; | |
color: #999; | |
} | |
h1 { | |
font-size: 32px; | |
margin: 16px 0 0 0; | |
} | |
</style> | |
</head> | |
<body> | |
<div> | |
@section('widgets') | |
@show | |
</div> | |
</body> | |
</html> |
This file contains hidden or 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
<?php | |
Route::get('/dashboard', function() | |
{ | |
return View::make('dashboard'); | |
}); | |
// Located on other module/package | |
View::composer('dashboard', function($view) | |
{ | |
$view->nest('widget1-section', 'widget1'); | |
}); | |
// Located on other module/package | |
View::composer('dashboard', function($view) | |
{ | |
$view->nest('widget2-section', 'widget2'); | |
}); | |
// Located on other module/package | |
View::composer('dashboard', function($view) | |
{ | |
$view->nest('widget3-section', 'widget3'); | |
}); |
This file contains hidden or 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
//Probably on another module/package | |
@section('widgets') | |
@parent | |
@section('widget1-section') | |
<h1>Widget One</h1> | |
@show | |
@stop |
This file contains hidden or 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
//Probably on another module/package | |
@section('widgets') | |
@parent | |
@section('widget2-section') | |
<h1>Widget Two</h1> | |
@show | |
@stop |
This file contains hidden or 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
//Probably on another module/package | |
@section('widgets') | |
@parent | |
@section('widget3-section') | |
<h1>Widget Three</h1> | |
@show | |
@stop |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment