From 20b20c28fd07d08b62ce829539d7b2729ec6d586 Mon Sep 17 00:00:00 2001
From: glmdev <glmdev@outlook.com>
Date: Fri, 30 Dec 2016 19:01:18 +0000
Subject: [PATCH] added metaWhere()

---
 src/Meta.php | 29 ++++++++++++++++++++++++++++-
 1 file changed, 28 insertions(+), 1 deletion(-)

diff --git a/src/Meta.php b/src/Meta.php
index 7f45cd6..f2eb5cd 100644
--- a/src/Meta.php
+++ b/src/Meta.php
@@ -156,6 +156,33 @@ class Meta extends Model implements MetaContract
         $table->uuid('uuid');
         $table->text('meta');
     }
-
+    
+    /**
+     * Allows the searching of models by a meta value.
+     * 
+     * @param mixed $key
+     * @param mixed $value
+     * 
+     * @return \Illuminate\Support\Collection
+     */
+    public static function metaWhere($key, $value){
+        $return = array();
+        
+        $models = self::all();
+        
+        foreach( $models as $model ){
+            
+            if ( $model->read($key) === $value ){
+                array_push($return, $model);
+            }
+            
+        }
+        
+        return collect($return);
+    }
+    
+    /**
+     * UNIMPLEMENTED
+     */
     public static function route(){}
 }
\ No newline at end of file