Been working in this for Hours, I want to print the Controller Variable in the Views. Here is my Code:
Controller:
$mydate=Carbon::now()->addHours(8);
$newdate=$mydate->toDateString();
$mydata = DB::table('attendances')->where('date_only', '=', $newdate)->get();
return View::make('Home')->with($mydata);
And here is my View
<div> {{$mydata}} </div>
I'm just getting error with this code
try this
$mydate=Carbon::now()->addHours(8);
$newdate=$mydate->toDateString();
$mydata = DB::table('attendances')->where('date_only', '=', $newdate)->get();
return View::make('Home',['mydata' => $mydata]); //just a different way to send vars to view
view:
instead of
<div> {{$mydata}} </div>
use this
<div> {{print_r($mydata)}} </div>
Have you tried
<div> {{ print_r($mydata->toArray())}} </div>
//or
<div> {{ print_r($mydata)}} </div>
//try this to know if you have got data in your $mydata
<div> {{ $mydata[0]->id }} </div> // id- a field name can change if u dont have one
or try this in your controller
$this->content = View::make('Home', array('mydata' => $mydata));