I can't get value of id from json string.
$photoIdObj = DB::table('images')->select('id')->whereJsonContains('name', ['path' => $photoPath])->get();
$jsonString = json_encode($photoIdObj, true); //object to json string conversion. Result: "[{"id":7}]"
$jsonArr = json_decode($jsonString); // json string to array
$photoId = $jsonArr->id;
//$selectedImages = \App\Image::where('id', $jsonString);
$selectedImages = \App\Image::findOrFail($photoId);
$selectedImages->forceDelete();
Error message:
"Trying to get property 'id' of non-object"
from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/3f03EXp
via IFTTT
Aucun commentaire:
Enregistrer un commentaire