You want to use "make" to build the view from the controller. Then you can set and pass variables to views and templates.
For my example assume the view lives at this path:
views/myViews/the_view.blade.php
... and assuming the template lives at this path:
views/templates/master.blade.php
<?php
class YourController extends BaseController {
public $restful = true;
public $layout = 'templates.master';
public function reportProfileStore() {
//All the stuff you want to do here
//Load the view with make
$view = View::make('myViews.the_view');
$view->viewVariableYouWant = 'Pass me to view';
$view->report_profiles = $report_profiles;
$this->layout->masterLayoutVariableYouWant = 'Pass me to template'
$this->layout->content = $view;
}
}
In the last line of that example I am setting the $view values to the template using a variable called content. Just make sure your master template is dumping that content variable somewhere..... eg
<body>
<div id="container">
<div id="nav-bar">@include('templates.navbar')</div>
<div id="top-bar">
<a href="/"><img id="logo" src="images/skin/logo.png" /></a>
</div>
<div id="example">{{$masterLayoutVariableYouWant}}</div>
<div id="main-content">{{$content}}</div>
<div id="footer-container">@include('templates.footer')</div>
</div>
</body>
Then your view looks like this
<h1>My View</h1>
<p>{{$viewVariableYouWant}}</p>
<ul>
@foreach($report_profiles as $profile)
<li>
{{$profile->id}}
</li>
@endforeach
</ul>
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community