Skip to content

Instantly share code, notes, and snippets.

@LeShadow
Created March 10, 2014 00:55
Show Gist options
  • Save LeShadow/9457610 to your computer and use it in GitHub Desktop.
Save LeShadow/9457610 to your computer and use it in GitHub Desktop.
laravel baseController function to be able to pass on standard settings defined in an array to your view.
BaseController.php, add the following:
protected function show_view($view, $tempData="")
{
$settings = array('setting1'=>'value');
$data = array();
if($tempData != "")
{
$data['data'] = $tempData;
}
$data['settings'] = $settings;
$this->layout->content = View::make($view, $data);
}
now in every controller you want to show a view, you can do this:
$this->show_view('viewname');
or if you want to pass on data:
$this->show_view('viewname', $data);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment