summaryrefslogtreecommitdiffstats
path: root/models/Anime.php
diff options
context:
space:
mode:
Diffstat (limited to 'models/Anime.php')
-rw-r--r--models/Anime.php19
1 files changed, 19 insertions, 0 deletions
diff --git a/models/Anime.php b/models/Anime.php
index ffa40eb..0877619 100644
--- a/models/Anime.php
+++ b/models/Anime.php
@@ -5,4 +5,23 @@ namespace app\models;
class Anime extends \lithium\data\Model {
protected $_meta = array('key' => '_id', 'source' => 'anime');
+ public static function search($query, $page = 1, $by = 'title')
+ {
+ $defaults = array(
+ 'limit' => 20
+ );
+
+ $limit = 20;
+
+ $content = self::find('all',
+ array(
+ 'conditions' => array(
+ $by => array('like' => $query)
+ ),
+ 'limit' => $limit,
+ 'page' => $page
+ ));
+ $total = Anime::count(array('title' => array('like' => $query)));
+ return compact('content', 'by', 'limit', 'total', 'page');
+ }
} \ No newline at end of file