laravel 5 startup

Setting up first route,view,controller and sending data to view laravel 5

Example Route

<?php
Route::get('home','HomeController@index');  // you tell if url has /home then home controller index function handles that
?>

Then Controller will be
app/Http/Controllers/HomeController.php

<?php
namespace App\Http\Controllers;
class HomeController extends Controller
{
	//this is the funtion handling the /home
	public function index(){
		$data = "abc"; // here is sample data
	    return View::make('home/myhome', array('data' => $data));  // this is html file will be saved in views/home/myhome.blade.php
	}

}
?>

resources/views/home/myhome.blade.php

{{ $data }} 
Advertisements