added metaWhere()
This commit is contained in:
parent
766e6a6c2c
commit
20b20c28fd
27
src/Meta.php
27
src/Meta.php
@ -157,5 +157,32 @@ class Meta extends Model implements MetaContract
|
||||
$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(){}
|
||||
}
|
Loading…
Reference in New Issue
Block a user