aurelkurtula
9/17/2013 - 11:39 PM

laravel:passing_variables

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
*/