Commit bc2186e5 by hfpp2012 yinsigan

给view传递变量

1 parent f5721e0e
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use View;
class PagesController extends Controller
{
public function index()
{
if (View::exists('pages.index'))
return view('pages.index')
->with('text', '<b>Laravel</b>')
->with('name', 'Nicole');
# return view('pages.index', ['text' => '<b>Laravel</b>', 'name' => 'Nicole']);
else
return 'No view available';
}
}
Hello, from index in pages folder.
<p>{!! $text !!}</p>
<p>{{ $text }}</p>
<p>{{ $name }}</p>
......@@ -11,9 +11,7 @@
|
*/
Route::get('/', function () {
return view('welcome');
});
Route::get('/', 'PagesController@index');
// Route::get('/users', function () {
// $users = [
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!