Answers
If you mean re-declare $jobTitle, yes you can. This is refactor version of your code (also i remove some unused variable)
$departmentUser = DepartmentUser::where('user_id', auth()->id())->first();
// If $departmentUser is Empty, make it null. Else find job title based on id
$jobTitle= !$departmentUser ?: JobTitle::find($departmentUser->job_title_id);
return view('dashboard.supplier.profile.basic-info.index', [
'user' => auth()->user(),
'jobTitle' => $jobTitle
]);
}
0 comments:
Post a Comment
Thanks