private static function getBuilderWithParam($find_sno, $find_name, $find_age) { $sno = false; $name = false; $age = false; if ($find_name) { $name = true; } if ($find_age) { $age = true; } if ($find_sno) { $sno = true; } $results = ArmyUpdates::where('s_no', '=', 0); // This returns an empty Builder obj // TODO : figure out better way $explanation = ""; if ($sno) { // This can only return one row (I think . TODO: check assumption) $results = ArmyUpdates::where('s_no', '=', $find_sno); $explanation = "Do not search on 'S.no.' and Another field together. 'S.no.' is unique for every update, so it will never match 2 records. This search is returning results for 'S.no.' = " . $find_sno . "."; } elseif ($name && !$age) { // Only Name Specified $results = Helper::searchTableForName(ArmyUpdates::TABLE_NAME, $find_name); // TODO : separate out exact matches and substr matches and disp them separately } elseif ($age && !$name) { // Only Age Specified $results = ArmyUpdates::where('age', '=', $find_age); } elseif ($name && $age) { // Name, Age Specified $results = Helper::searchTableForNameAndAge(ArmyUpdates::TABLE_NAME, $find_name, $find_age); // TODO : separate out exact matches and substr matches and disp them separately } return $results; }