В моем проекте Laravel -5.8, когда я отправил следующий код:
public function publish_all_posts(){
$userCompany = Auth::user()->company_id;
$userEmployee = Auth::user()->employee_id;
$userId = Auth::user()->id;
$userEmail = Auth::user()->email;
$userCode = Auth::user()->employee_code;
$userFirstName = Auth::user()->first_name;
$userLastName = Auth::user()->last_name;
$identities = DB::table('appraisal_identity')->select('id')->where('company_id', $userCompany)->where('is_current', 1)->first();
$reviewperiods = DB::table('appraisal_identity')->select('appraisal_name')->where('company_id', $userCompany)->where('is_current', 1)->first();
$reviewperiod = $reviewperiods->appraisal_name;
$linemanager = DB::table('hr_employees')->where('id', $userEmployee)->first();
$linemanageruserid = DB::table('hr_employees')->select('line_manager_id')->where('line_manager_id', $linemanager->line_manager_id)->first();
$linemanageruserids = DB::table('hr_employees')->where('id', $linemanageruserid->line_manager_id)->first();
$linemanageremails = DB::table('hr_employees')->select('email')->where('id', $linemanageruserids->id)->first();
$linemanageremail = $linemanageremails->email;
if ($unapproved_count > 3){
$unapproved_post = AppraisalGoal::where('employee_id', $userEmployee)->where('appraisal_identity_id', $identities->id)->where('is_published',0)
->update([
'is_published' => 1,
'is_approved' => 1
]);
$unapproved_post = AppraisalGoal::where('employee_id', $userEmployee)->where('appraisal_identity_id', $identities->id)->where('is_published',1)->first();
Session::flash('success', 'Goals Published successfully');
return redirect()->back();
}else{
Session::flash('info', 'You cannot proceed. Kindly Set all Goals before you publish!');
return redirect()->back();
}
}
Я получил эту ошибку:
Попытка получить свойство 'id' из необъект
и эта строка кода была выделена:
$linemanageremails = DB::table('hr_employees')
->select('email')
->where('id', $linemanageruserids->id)
->first();
Я обнаружил, что ошибка произошла потому что: $ linemanageruserids имеет значение NULL
Как сделать Я разрешаю это?