For example, I have JSON stored in a Row of a database called 'data'
External.php (model) - casting 'data' to an array:
protected $casts = [
'data' => 'array',
];
I can access it using Tinker with this commmand:
$external = App\External::first()->pluck('data');
This returns
Illuminate\Support\Collection {#3384
all: [
[
"id" => 17566616456845,
"name" => "#1008",
"note" => "",
"tags" => "",
"test" => false,
"email" => "[email protected]",
"phone" => null,
...
..
.
How do I access the "email" or "id" from that collection? How do I modify the tinker eloquent command to get the "id" or "email"?
$external = App\External::all()->pluck('data')->'email'
T_STRING or T_VARIABLE or '{' or '$' on line 1> Exception with message 'Property [email] does not exist on this> PHP Parse error: Syntax error, unexpected T_CONSTANT_ENCAPSED_STRING, expecting
Getting warmer:
>>> $external = App\External::pluck('data')->get('email')
=> null