been looking all evening and it all seems so easy and simple but just won't work!
Just starting out and trying to get a variable into a view.
Whatever i do, i can't seem to read it.
routes.php:
Route::get('/', function()
{
return View::make('dashboard');
});
View::composer('dashboard', function($view) {
$view->with('links', "something");
});
dashboard.blade.php:
@extends('base_view')
@section('content')
All the stuff!
{{links}}
@stop
base_view.blade.php
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Laravel PHP Framework</title>
</head>
<body>
<div>TeamPro</div>
<div>@yield('content')</div>
</body>
</html>
Please tell me i'm just doing something stupid!
Use $links
, not links
:
@section('content')
All the stuff!
{{ $links }}
@stop
Every variable in PHP should be preceded by a $
sign. If there's no $
, PHP treats it as a constant.
It's just a simple syntax issue, everything you send to a view is a php variable so still needs to be referenced with the $
In your view, you are referencing links
without the dollar sign.
If you update it to:
{{ $links }}
You'll be A-OK
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With