added metaWhere()
This commit is contained in:
parent
766e6a6c2c
commit
20b20c28fd
29
src/Meta.php
29
src/Meta.php
@ -156,6 +156,33 @@ class Meta extends Model implements MetaContract
|
|||||||
$table->uuid('uuid');
|
$table->uuid('uuid');
|
||||||
$table->text('meta');
|
$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(){}
|
public static function route(){}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user