for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace Staudenmeir\LaravelAdjacencyList\Eloquent;
use Illuminate\Database\Eloquent\Model;
use Staudenmeir\LaravelAdjacencyList\Eloquent\Traits\HasAdjacencyList;
use Staudenmeir\LaravelCte\Eloquent\QueriesExpressions;
trait HasRecursiveRelationships
{
use HasAdjacencyList;
use QueriesExpressions;
public function isParentOf(Model $model)
return $this->children->contains($model);
}
public function isChildOf(Model $model)
return $this->parent ? $this->parent->is($model) : false;
public function depthRelatedTo(Model $model)
$currentModel = $this->bloodline->firstWhere('id', $this->getKey());
getKey()
If this is a false-positive, you can also ignore this issue in your code via the ignore-call annotation
ignore-call
$currentModel = $this->bloodline->firstWhere('id', $this->/** @scrutinizer ignore-call */ getKey());
$relatedModel = $this->bloodline->firstWhere('id', $model->getKey());
if ($currentModel && $relatedModel) {
return $currentModel->depth - $relatedModel->depth;
return null;