/** * Fetch a list of users based on the value of a given column. Returns empty array if no match is found. * * @param value $value The value to find. (defaults to null, which means return all records in the table) * @param string $name The name of the column to match (defaults to null) * @return array An array of User objects */ public static function fetchAll($value = null, $name = null) { if (!$value || !$name) { $result = OAuthUser::all(); } else { $result = OAuthUser::where($name, $value)->get(); } $users = []; foreach ($result as $user) { $users[$user->id] = $user; } return $users; }