added metaWhere()

This commit is contained in:
glmdev 2016-12-30 19:01:18 +00:00
parent 766e6a6c2c
commit 20b20c28fd

View File

@ -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(){}
}