Skip to content

Instantly share code, notes, and snippets.

@aurelkurtula
Last active December 23, 2015 07:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aurelkurtula/6602290 to your computer and use it in GitHub Desktop.
Save aurelkurtula/6602290 to your computer and use it in GitHub Desktop.
laravel:passing_variables
<?php
Route::get('/', function() //the point represents a slash. So index page is at views/home/index.blade.php
{
$greeting = "From home page ";
$thing = "doing my thing";
return View::make('home.index')->with(
array(
'greeting' => $greeting ,
'thing' => $thing)
);
});
Route::get('/array', function() //the point represents a slash. So index page is at views/home/index.blade.php
{
$data = array(
'greeting' => 'From about page' ,
'thing' => "doing my thing"
);
return View::make('home.index', $data);
});
Route::get('/view', function() //the point represents a slash. So index page is at views/home/index.blade.php
{
$view = View::make('home.index');
$view->greeting = "from views";
$view->thing = "page";
return $view;
}) ;
/*
in the home/index view we add
echo $greeting
echo $thing
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment