I am facing a problem while fetching the data from database
view.php
<p>attend</p>
@foreach($attendings as $attending)
@if ($attending->acceptance==1)
{{ $attending->membername }}
@endif
@endforeach
<p>not attend</p>
@foreach($attendings as $attending)
@if ($attending->acceptance==0)
{{ $attending->membername }}
@endif
@endforeach
<br>
<br>
<p>final decision </p>
{{ $attendings->editor_com }}
controller
public function attendx()
{
$attendings = DB::table('attendance')->get();
return view('My_Work.report', ['attendings' => $attendings]);
}
routes
get('/editor/report','DatabaseController@attendx');
But what I'm facing is Undefined variable: attendings
What am I doing wrong?
Note: I am writing the codes in laravel 5.1
You are returning attendings to this view file My_Work.report.blade.php
So you have to place all your code in report.blade.php file .
Remove this line
{{ $attendings->editor_com }}
because this will throw error Trying to get property of non-object