in this result of
{#457 ▼
+"id": 14
+"amount": "110092"
+"discount": 0
+"images": "{"images":{"original":"\/uploads\/post_images\/2017\/1513070310.jpeg","300":"\/uploads\/post_images\/2017\/300_1513070310.jpeg","600":"\/uploads\/post_images\/2017\/600_1513070310.jpeg","900":"\/uploads\/post_images\/2017\/900_1513070310.jpeg"},"thumbnail":"\/uploads\/post_images\/2017\/300_1513070310.jpeg"} ◀"
+"created_at": "2017-12-28 17:48:48"
+"updated_at": "2017-12-28 19:24:18"
}
query, i'm trying to get thumbnail
from images column which images
is JsonObject
, but i get this error:
"Illegal string offset 'thumbnail'"
my code:
$userShoppings = \DB::table('payments as s')
->join('products as p', 's.product_id', '=', 'p.id')
->select('p.*', 's.*',\DB::raw('s.ordering_count * s.price as cost'))
->whereUserId(auth()->user()->id)
->first();
dd($userShoppings->images['thumbnail']);
or
dd($userShoppings->images['images']['thumbnail']);
error:
"Illegal string offset 'images'"
my models:
class Shopping extends Model
{
protected $fillable = [];
protected $casts=[
'images'=>'array'
];
}
class Payment extends Model
{
protected $fillable = [];
protected $casts=[
'images'=>'array'
];
}
from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2lmT2pr
via IFTTT
Aucun commentaire:
Enregistrer un commentaire