dever 4 years ago
parent
commit
0005bf2bac
1 changed files with 6 additions and 0 deletions
  1. 6 0
      src/Api.php

+ 6 - 0
src/Api.php

@@ -32,6 +32,12 @@ class Api
 
 		$template = Dever::db('poster/template')->getAll($where);
 
+		$total = count($template);
+
+		if ($num > $total) {
+			$num = $total;
+		}
+
 		$key = array_rand($template, $num);
 
 		if (is_array($key)) {