php - Passing Data to view - Undefined variable -
i'm new laravel framework , somehow got issue bothers me days now.
i wanted pass simple variable blade view, version found in documentation or question on platform unfortunately didn't lead solution.
i created route looks this:
route::get('test', 'pagecontroller@index');
the code in pagecontroller
looks this:
public function index(){ $datatopass='datahere'; return view('admin.test', compact('datatopass')); }
and got view looks this:
@section('content') {{$datatopass}} @stop
the problem 2 exeptions:
#errorexception in d9e848d01f99ac2368ead804bd322152 line 3: undefined variable: datatopass (view: /home/vagrant/test/resources/views/admin/test.blade.php) errorexception in d9e848d01f99ac2368ead804bd322152 line 3: undefined variable: datatopass
i'm using homestead development environment set in virtualbox.
any ideas i've done wrong?
i tried every type of datapassing like
return view('test')->with('datatopass', $datatopass)` //or return view('datatopass', $datatopass)
and on.
i'll greateful help.
try this::
return view('test')->with('datatopass', $datatopass);
and in view access as
<?php echo $datatopass ?>
Comments
Post a Comment