mirror of
https://github.com/Karaka-Management/phpOMS.git
synced 2026-01-11 09:48:40 +00:00
added get by parent function
This commit is contained in:
parent
6a6351a275
commit
2a3d273f99
|
|
@ -182,6 +182,14 @@ class DataMapperAbstract implements DataMapperInterface
|
|||
*/
|
||||
protected static string $table = '';
|
||||
|
||||
/**
|
||||
* Parent column.
|
||||
*
|
||||
* @var string
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected static string $parent = '';
|
||||
|
||||
/**
|
||||
* Model to use by the mapper.
|
||||
*
|
||||
|
|
@ -2826,6 +2834,24 @@ class DataMapperAbstract implements DataMapperInterface
|
|||
return self::getAllByQuery($query, $relations, $depth);
|
||||
}
|
||||
|
||||
/**
|
||||
* Parent parent.
|
||||
*
|
||||
* @param int $depth Relation depth
|
||||
* @param mixed $value Parent value id
|
||||
*
|
||||
* @return array
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public static function getByParent($value, int $depth = 3) : array
|
||||
{
|
||||
$query = self::getQuery();
|
||||
$query->where(static::$table . '_' . $depth . '.' . static::$parent, '=', $value);
|
||||
|
||||
return self::getAllByQuery($query, RelationType::ALL, $depth);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all by custom query.
|
||||
*
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user