uuid 값을 저장하는 기본 키가 string
인 테이블이 있습니다. 데이터 쿼리를하면 모든 것이 잘됩니다. 하지만 모든 ID의 배열을 얻으려면 pluck('id')
을 사용할 때 배열이 0이됩니다! pluck('firstName')
으로 테스트하려고 시도했지만 이름 배열을 반환합니다. 'firstName'
을 'id'
으로 바꿀 때 나는 0 값의 배열을 얻습니다.pluck ('id')는 문자열 값을 0으로 변환합니다.
id
값을 pluck하면 int
으로 자동 변환 되나요? 이 문제를 해결할 수있는 방법이 있습니까? 기본적으로
public $incrementing = false;
는 Laravel은 기본 키가 숫자 값이 될 것으로 기대하고 int
로 변환 :
$p = \App\Profile::all()->take(5)
=> Illuminate\Database\Eloquent\Collection {#1015
all: [
App\Profile {#980
id: "client.121138f1-e999-35a1-a16",
phone: "496.533.3798",
firstName: "Gabriella",
lastName: "Steuber",
company: "",
email: "[email protected]",
city_id: 1,
address: """
353 Nolan Stravenue\n
Gudrunshire, MN 36601-6307
""",
isCompany: 0,
status: 1,
state: "active",
role: "client",
created_at: "2017-11-05 11:59:49",
updated_at: "2017-11-05 11:59:49",
deleted_at: null,
},
App\Profile {#1004
id: "client.1eac4f8c-e020-31df-96c",
phone: "290.757.1167 x",
firstName: "Yadira",
lastName: "Dietrich",
company: "",
email: "[email protected]",
city_id: 1,
address: """
9202 Joaquin Court\n
New Hattiebury, TN 90934
""",
isCompany: 0,
status: 1,
state: "active",
role: "client",
created_at: "2017-11-05 11:59:49",
updated_at: "2017-11-05 11:59:49",
deleted_at: null,
},
App\Profile {#1003
id: "client.791724a8-18f5-3060-bb6",
phone: "(989) 841-4920",
firstName: "Ashleigh",
lastName: "Beahan",
company: "",
email: "[email protected]",
city_id: 1,
address: """
94164 Ross Meadow\n
Port Helmerside, PA 44559-1028
""",
isCompany: 0,
status: 1,
state: "active",
role: "client",
created_at: "2017-11-05 11:59:49",
updated_at: "2017-11-05 11:59:49",
deleted_at: null,
},
App\Profile {#982
id: "client.adb2e488-c980-3fa6-a82",
phone: "775.719.8987",
firstName: "Raoul",
lastName: "Buckridge",
company: "",
email: "[email protected]",
city_id: 1,
address: """
299 Kianna Dam\n
Port Thea, VT 49661-6377
""",
isCompany: 0,
status: 1,
state: "active",
role: "client",
created_at: "2017-11-05 11:59:49",
updated_at: "2017-11-05 11:59:49",
deleted_at: null,
},
App\Profile {#981
id: "client.af2a8c1f-da5c-3e50-8f8",
phone: "1-682-709-5461",
firstName: "Alexandre",
lastName: "Koelpin",
company: "",
email: "[email protected]",
city_id: 1,
address: """
55646 Blick Oval Suite 052\n
Remingtonberg, TN 24963-8386
""",
isCompany: 0,
status: 1,
state: "active",
role: "client",
created_at: "2017-11-05 11:59:49",
updated_at: "2017-11-05 11:59:49",
deleted_at: null,
},
],
}
$p->pluck('firstName')
=> Illuminate\Support\Collection {#1018
all: [
"Gabriella",
"Yadira",
"Ashleigh",
"Raoul",
"Alexandre",
],
}
$p->pluck('id')
=> Illuminate\Support\Collection {#1009
all: [
0,
0,
0,
0,
0,
],
}