how to get data from json object in laravel code example
Example 1: how get value of json encode in laravel
$json = '{"countryId":"84","productId":"1","status":"0","opId":"134"}';
$json = json_decode($json, true);
echo $json['countryId'];
echo $json['productId'];
echo $json['status'];
echo $json['opId'];
Example 2: php laravel return json response
return response()->json([
'name' => 'Abigail',
'state' => 'CA'
]);
Example 3: laravel json response
return response()->json([
'name' => 'Abigail',
'state' => 'CA',
]);
Example 4: laravel json eloquent
protected $casts = [
'birthday' => 'date:Y-m-d',
'joined_at' => 'datetime:Y-m-d H:00',
];