dever 4 years ago
parent
commit
bd54f1fdd3
1 changed files with 18 additions and 1 deletions
  1. 18 1
      src/Api.php

+ 18 - 1
src/Api.php

@@ -32,7 +32,24 @@ class Api
 
 		$template = Dever::db('poster/template')->getAll($where);
 
-		$key = array_rand($template, 1);
+		$key = array_rand($template, $num);
+
+		if (is_array($key)) {
+			$result = array();
+			foreach ($key as $k => $v) {
+				$result[] = $this->getTemplate($set, $template, $v, $name, $update);
+			}
+
+			return $result;
+		} else {
+			return $this->getTemplate($set, $template, $key, $name, $update);
+		}
+		
+		return false;
+	}
+
+	private function getTemplate($set, $template, $key, $name, $update)
+	{
 		$template = $template[$key];
 
 		if ($template) {