im having a problem with my code.
I want to show the record of the student who login but im having an
undefined variable on my view.blade
Here's my Model
class Attendance extends Eloquent {
public function users()
{
return $this->belongsTo('User', 'id');
}
}
Here's my Controller
public function viewstudentAttendance()
{
$students = Auth::user()->id;
//load view and pass users
return View::make('student.view')
->with('attendances', $students);
}
Finally here's my view.blade
@extends('layouts.master')
@section('head')
@parent
<title>View Attendance</title>
@stop
{{ HTML::style('css/bootstrap.css'); }}
@section('content')
</ul>
@if ($students->count())
<table class="table table-striped table-bordered">
<thead>
<tr>
<th>ID</th>
<th>First name</th>
<th>Last name</th>
</tr>
</thead>
<tbody>
@foreach ($students as $students)
<tr>
<td>{{ $students->id }}</td>
<td>{{ $students->firstname }}</td>
<td>{{ $students->lastname }}</td>
@endforeach
</tr>
{{ HTML::script('js/bootstrap.js'); }}
</tbody>
</table>
@else
There are no attendance recorded yet
@endif
@stop
I think the problem is with my view or how i declare the variable? Please help? :(
attendancesand notstudents