Closed aldesrahim closed 6 months ago
for additional information:
this is the query that generated using HasOneThrough
:
select coa_parent.*, `coas`.`id` as `laravel_through_key` from coas AS coa_parent inner join `coas` on `coa_parent`.`id` = `coas`.`parent_id` where `coas`.`id` in ('9be3cb15-c23b-4bfe-80f3-3f9f02714c2e')```
and this is the query that generated using this package:
select `coas`.*, `coa_sibling`.`id` as `laravel_through_key` from `coas` inner join `coas` as `coa_sibling` on `coa_sibling`.`parent_id` = `coas`.`id` where `coa_sibling`.`id` in (null)
Hi @aldesrahim, The package doesn't support this particular case.
Use one of my other packages instead: https://github.com/staudenmeir/eloquent-has-many-deep
class Cashbank extends Model
{
use \Staudenmeir\EloquentHasManyDeep\HasRelationships;
public function coa()
{
return $this->hasOneDeep(Coa::class, [Coa::class . ' as alias'], ['id', 'id'], ['coa_id', 'parent_id']);
}
}
Thank you, it is working now
Hi, i have this schema
and i have this data
basically i want to eagerLoad "coa parent" when retrieving "cashbank", so i've figured this out using
HasOneThrough
, but the code looks bit messy, and i'm trying to use this package (if possible)this the code i implemented using this package
and this the code i implemented using
HasOneThrough