mirror of
https://github.com/Karaka-Management/phpOMS.git
synced 2026-02-08 21:28:40 +00:00
Adjust find method
This commit is contained in:
parent
3d77fd8e35
commit
8c53047ee4
|
|
@ -74,14 +74,14 @@ interface DataMapperInterface
|
||||||
/**
|
/**
|
||||||
* Find data.
|
* Find data.
|
||||||
*
|
*
|
||||||
* @param array $columns Columns
|
* @param string $search Search
|
||||||
*
|
*
|
||||||
* @return Builder
|
* @return array
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||||
*/
|
*/
|
||||||
public static function find(...$columns) : Builder;
|
public static function find(string $search) : array;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* List data.
|
* List data.
|
||||||
|
|
|
||||||
|
|
@ -296,25 +296,27 @@ class DataMapperAbstract implements DataMapperInterface
|
||||||
/**
|
/**
|
||||||
* Find data.
|
* Find data.
|
||||||
*
|
*
|
||||||
* @param array $columns Columns
|
* @param string $search Search for
|
||||||
*
|
*
|
||||||
* @return Builder
|
* @return Builder
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||||
*/
|
*/
|
||||||
public static function find(...$columns) : Builder
|
public static function find(string $search) : array
|
||||||
{
|
{
|
||||||
self::extend(__CLASS__);
|
self::extend(__CLASS__);
|
||||||
|
|
||||||
if (count($columns) === 0) {
|
$query = static::getQuery();
|
||||||
$columns = [static::$table . '.*'];
|
|
||||||
|
foreach(static::$columns as $col) {
|
||||||
|
if(isset($col['autocomplete']) && $col['autocomplete']) {
|
||||||
|
$query->where($col['name'], 'LIKE', $search, 'OR');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$query = new Builder(self::$db);
|
|
||||||
$query->prefix(self::$db->getPrefix());
|
return static::getAllByQuery($query);
|
||||||
|
|
||||||
return $query->select(...$columns)->from(static::$table);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user