did you try $collection->pluck('strand_id')?
Feb 21, 2017
11
Level 1
Pluck from a nested collection?
Hi, I'm trying to pluck the strand_id value from the following collection
Illuminate\Database\Eloquent\Collection {#3820
all: [
App\Activity {#3814
id: 1,
title: "Test activity number one",
provider: "Some provider",
description: "Here is a description",
hours: "3.00",
date: "2017-02-21",
deleted_at: null,
created_at: "2017-02-21 10:19:52",
updated_at: "2017-02-21 10:19:52",
pls: Illuminate\Database\Eloquent\Collection {#3827
all: [
App\ParticipantLevelStrand {#3829
id: 1,
participant_level_id: 1,
strand_id: 1,
pivot: Illuminate\Database\Eloquent\Relations\Pivot {#3826
activity_id: 1,
pls_id: 1,
},
},
],
},
},
$collection->pluck('pls') works fine but when i'm trying to nest the query to $collection->pluck('pls.strand_id') I get null. Am I missing something obvious here?
Please or to participate in this conversation.