ErrorException试图获取非对象的属性

时间:2017-08-27 01:24:04

标签: php laravel-5.4

您好我在这里遇到以下错误:

at HandleExceptions->handleError(8, 'Trying to get property of non-object', 'C:\\wamp64\\www\\gesetud\\app\\Http\\Controllers\\FeeController.php', 99, array('viewName' => 'fee.payment', 'student_id' => '4', 'feetypes' => object(Collection), 'status' => null))in FeeController.php (line 99)

at FeeController->payment('fee.payment', '4')in FeeController.php (line 124)

使用此路线时

Route::get('/etudiant/aller/a/payement/{student_id}',['as'=>'goPayment','uses'=>'FeeController@goPayment']);

这里的' goPayment'方法行124:

 public function goPayment($student_id)
{
    return $this->payment('fee.payment',$student_id);
}

这里第99行是$ programs = Program :: where ....:

 public function payment($viewName,$student_id)
{
    $feetypes = FeeType::all();
    $status = $this->student_status($student_id);
    $programs = Programme::where('program_id',$status->program_id)->get();
    $levels = Niveau::where('program_id',$status->program_id)->get();
    $studentfee = $this->show_school_fee($status->level_id)->first();
    $readStudentFee = $this->read_student_fee($student_id)->get();
    $readStudentTransaction = $this->read_student_transaction($student_id)->get();
    $receipt_id = ReceiptDetail::where('student_id',$student_id)->max('receipt_id');
    return view($viewName,compact('programs',
                                    'levels',
                                    'status',
                                    'studentfee',
                                    'receipt_id',
                                    'readStudentFee',
                                    'readStudentTransaction',
                                    'feetypes'))
                                    ->with('student_id',$student_id);

1 个答案:

答案 0 :(得分:0)

这里有student_status功能:

public function student_status($studentId)
{
    return Status::latest('statuses.status_id')
            ->join('students','students.student_id','=','statuses.student_id')
            ->join('classes','classes.class_id','=','statuses.class_id')
            ->join('academics','academics.academic_id','=','classes.academic_id')
            ->join('shifts','shifts.shift_id','=','classes.shift_id')
            ->join('times','times.time_id','=','classes.time_id')
            ->join('groups','groups.group_id','=','classes.group_id')
            ->join('batches','batches.batch_id','=','classes.batch_id')
            ->join('levels','levels.level_id','=','classes.level_id')
            ->join('programs','programs.program_id','=','levels.program_id')
            ->where('students.student_id',$studentId)
            ->first();
}