Improved Search Functionality
This commit is contained in:
@ -17,8 +17,9 @@ use TheTempusProject\Bedrock\Functions\Check;
|
||||
use TheTempusProject\Bedrock\Bedrock;
|
||||
|
||||
class DatabaseModel extends Model {
|
||||
public $databaseMatrix;
|
||||
public $tableName;
|
||||
public $databaseMatrix;
|
||||
public $searchFields;
|
||||
|
||||
public function __construct() {
|
||||
parent::__construct();
|
||||
@ -190,4 +191,19 @@ class DatabaseModel extends Model {
|
||||
}
|
||||
return $this->filter( $data->results() );
|
||||
}
|
||||
|
||||
public function search($param) {
|
||||
if (empty($this->searchFields)) {
|
||||
Debug::log('searchFields is empty');
|
||||
return [];
|
||||
}
|
||||
|
||||
$result = self::$db->search($this->tableName, $this->searchFields, $param);
|
||||
|
||||
if ( $result->count() ) {
|
||||
return $this->filter( $result->results() );
|
||||
}
|
||||
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user