Obviously, I don't know much of the background to the original poster's question, but to me, this looks like something better handled in a scope.
public function tasks() {
return $this->hasMany('Tasks','startTarget')->orWhere('endTarget','=',$this->id);
}
public function scopeOpen($query) {
return $query->where('status', '=', 0);
}
Then retrieval would look something like:
$target->tasks()->open()->get();
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community