private function generateCode() { $spendings = Spending::where('project_id', '=', Auth::user()->curr_project_id)->where('location_id', '=', Auth::user()->location_id)->where('spendable_type', '=', 'Classification')->count(); $spendings += 1; $code = Auth::user()->curr_project->code . Auth::user()->location->code . '02' . $spendings; return $code; }