Reputation:
I have created a calculation form in Laravel Scheduler that works perfectly. Now I have copied the same code to inside "Controller," but it doesn't work, giving the error message: "Unsupported operand types."
Code:
$client = new \GuzzleHttp\Client();
$response = $client->request('GET', $request['url_getmasternodecount']);
$response->getStatusCode();
$result = $response->getBody();
$getmasternodecount = json_decode($result, true);
$client = new \GuzzleHttp\Client();
$response = $client->request('GET', $request['url_getdifficulty']);
$response->getStatusCode();
$result = $response->getBody();
$getdifficulty = json_decode($result, true);
$blockreward = 2222222/$getdifficulty+2600/9^2;
$chain_second = 86400/$request['chain_second'];
$mnreward = $request['mnreward']/100;
$roi = 1/$getmasternodecount*$blockreward*$mnreward*$chain_second*365/1000;
On the last line, Laravel say there is some error. Can someone help me with this?
Upvotes: 0
Views: 2038
Reputation: 16339
You are likely trying to perform mathematical operations on an array.
This code here stands out:
$getdifficulty = json_decode($result, true);
$blockreward = 2222222/$getdifficulty+2600/9^2;
At this point, $getdifficulty
is an array, and you are trying to use it to divide 2222222 and then add figures to it.
You are doing the same thing with $getmasternodecount
.
Upvotes: 1