This seems pretty straightforward, but haven't had any luck. I have one to many Task to Block relationship. The relationships: Task->blocks:
public function blocks()
{
return $this->hasMany(Block::class, 'task_uuid', 'task_uuid');
}
Blocks->task:
public function task()
{
return $this->belongsTo(Task::class, 'task_uuid', 'task_uuid');
}
With that I can get all of a task's blocks like so: $task->blocks;. I'm trying to pluck all plucks from a collection of tasks: $tasks->pluck('blocks') and use a local scope that is on the Block model:
public function scopeUnresolved($query)
{
return $query->where('resolved_at', null);
}
Some of my attempts (even the super dumb ones): $tasks->pluck('blocks')->unresolved()->get(); $tasks->pluck('blocks')->flatten()->unresolved()->get(); $tasks->pluck('blocks')->filter()->all()->unresolved()->get(); and a few others as well. Any insights on this? Thanks!
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire