I have this query:
$companyId = Auth::user()->company_id;
$userId = Auth::user()->id;
$employeeId = Auth::user()->employee_id;
$employeeCode = Auth::user()->employee_code;
$identities = DB::table('appraisal_identity')->select('id')->where('company_id', $companyId)->where('is_current', 1)->first();
This is the query that should yield final result:
$goals = Goal::where('employee_id', $employeeId)->where('appraisal_identity_id', $identities->id)->where('is_approved', 3)->orWhere('is_visible', 0)->whereNull('deleted_at')->orderBy('goal_type_id')->get();
I want to display the goals dor the logged in empoyee (current user). In the goals table, for the employee, is_approved = 3 or is_visible =0.
I mean
$goals = Goal::where('employee_id', $employeeId)->where('appraisal_identity_id', $identities->id)->where('is_approved', 3)->orWhere('is_visible', 0)->whereNull('deleted_at')->orderBy('goal_type_id')->get();
is not giving the desired result
But I see from the result that the query bypassed where('employee_id', $employeeId) and display the result for all the employees and not just the logged in user.
How do I correct this?
Thanks