public function settledReports() { //Get all reports for the user - owned + associated $expenseReports = ExpenseReport::where(function ($query) { $query->where('owner_id', '=', $this->id)->orWhereHas('users', function ($query) { $query->where('user_id', '=', $this->id); }); //And check for settlement conditions })->where(function ($query) { //Report is completely settled $query->where('status', '>=', 3)->orWhere(function ($query) { $query->where('status', '=', 2)->whereDoesntHave('settlements', function ($query) { $query->where('completed', '=', 0)->where(function ($query) { $query->where('owee_id', '=', $this->id)->orWhere('owed_id', '=', $this->id); }); }); }); }); return $expenseReports; }
public function listAllExpensesReports() { $expensesReports = ExpenseReport::where('mr_id', \Auth::user()->id)->get(); $dataView = ['expensesReports' => $expensesReports]; return view('mr.expense_report.list', $dataView); }