Closed marensas closed 1 year ago
Hi @marensas, The package doesn't support graph relationships yet, but I'm working on that.
Do you need to apply a limit to a graph relationship (e.g. ancestors
) or only to some of your own relationships?
Do you know need to apply a limit to a Graph relationship (e.g.
ancestors
) or only to some of your own relationships?
Currently I'm applying limit only to direct relationships. But I see usefull cases where limit could be applied to ancestors i.e. getting a tree with "latest" ancestors etc.
I asked because I haven't found a solution for supporting limits on graph relationships yet.
However, I released a new version with the trait for graph relationships so you can at least apply limits to your direct relationships:
class Kpi extends Model
{
use \Staudenmeir\EloquentEagerLimitXLaravelAdjacencyList\Eloquent\HasEagerLimitAndGraphRelationships;
}
Code:
Command:
Kpi::find(2557)->ancestors
Error:
SQLSTATE[42S22]: Column not found: 1054 Unknown column 'laravel_cte.from_kpi_id' in 'on clause' (Connection: mysql, SQL: with recursive `laravel_cte` as ((select *, -1 as `depth`, cast(`id` as char(65535)) as `path` from `kpis` where `kpis`.`id` is null) union all (select `kpis`.*, `depth` - 1 as `depth`, concat(`path`, ., `kpis`.`id`) from `kpis` inner join `laravel_cte` on `laravel_cte`.`from_kpi_id` = `kpis`.`id`)) select * from `laravel_cte` where `laravel_cte`.`deleted_at` is null).
When using only
laravel-adjacency-list
works fine.