且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Laravel:未定义的变量

更新时间:2023-02-22 14:18:56

public function viewstudentAttendance() {
    //This code turns ID ONLY Check the website out for a code that retrieves data so you can loop it.
    $students = Auth::user() - > id;
    //Code that counts number of student
    $studentCount = XXX(Google It)
    //load view and pass users  
    return View::make('student.view') - > with('attendances', $students);
    //Return StudentCount too
}

在您的刀片模板中,使用:

Inside your blade template, use :

@if ($studentCount > 10)

而不是

@if ($students->count())

您的学生正在返回身份证件,您如何计数

Your students is returning ID, how could you "Count"

http://laravel.com/docs/4.2/eloquent

在你的刀片中,你一直在做,如果($学生)bla bla,只是为了让你知道这是参加者

Inside your blade you kept doing if($students) bla bla, just to let you know it's attendances

- > with('attendances',$ students);

->with('attendances', $students);

出席人数是您的刀片可以看到的变量,$ student是您正在推送刀片的数据。

Attendances is the variable your blade will see, $student is the data you are pushing into attendances for blade