If I try to make a deposit, an error keeps popping up. I use to make deposits without any error. It points to this direction:
C:\xampp\htdocs\mysystem\vendor\symfony\http-foundation\Response.php
This is the error That pops up in the browser.
public function setContent($content)
{
if (null !== $content && !\is_string($content) && !is_numeric($content) && !\is_callable([$content, '__toString'])) {
throw new \UnexpectedValueException(sprintf('The Response content must be a string or object implementing __toString(), "%s" given.', \gettype($content)));
}
$this->content = (string) $content;
return $this;
}
My controller
class DepositTransactionsController extends Controller
{
public function createDeposit(){
return view('agent_dashboards.add_customer_deposit');
}
public function saveDeposit(Request $request){
$this->validate($request,[
'customer_id' => 'required|exists:customers',
'amount' => 'required'
]);
$customer = Customer::where('customer_id',$request->input('customer_id'))->first();
$deposit_trans = new DepositTransaction();
$deposit_trans->customer_id = $customer->id;
$deposit_trans->agent_id = Auth::user()->id;
$deposit_trans->amount = $request->input('amount');
// add sms api
$response = $this->urlBuilder($customer->phone_number, $request->input('amount'));
if(strpos($response, 'SUCCESS') === false){
return $response;
}else{
$deposit_trans->sms_notification_status = "SENT";
$deposit_trans->save();
}
$customer->total_savings = $customer->total_savings + $request->input('amount');
$customer->save();
$temp_deposit_sum_record = TemporaryDailyDeposit::where('agent',Auth::user()->firstname.' '.Auth::user()->surname)->first();
if($temp_deposit_sum_record == null){
$temp_deposit_sum_record = new TemporaryDailyDeposit();
$temp_deposit_sum_record->agent = Auth::user()->firstname.' '.Auth::user()->surname;
$temp_deposit_sum_record->total_amount_recieved = $request->input('amount');
$temp_deposit_sum_record->save();
}else{
$temp_deposit_sum_record->total_amount_recieved += $request->input('amount');
$temp_deposit_sum_record->save();
}
return redirect('/home');
}
private function urlBuilder($number, $amount){
$username = "";
$password = "";
$from = "";
$to = $this->getPhoneNumber($number);
$message = $this->getMessage($amount);
$baseurl = "https://isms.wigalsolutions.com/ismsweb/sendmsg/";
$params = "username=".$username."&password=".$password."&from=".$from."&to=".$to."&message=".$message;
//send message
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $baseurl);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS,$params);
$response = curl_exec($ch);
curl_close($ch);
return $response;
}
private function getPhoneNumber($number){
if(strlen($number) == 13){
return substr($number,1);
}else{
return "233".substr($number,1);
}
}
private function getMessage($amount){
$message = "Dear valued customer,\n We wish to notify you that, we have recieved your deposit of GHc"
.number_format($amount, 2, '.', '')." into your account on this date: ".date("Y-m-d")
."\n Thank you for the transaction.";
return $message;
}
public function showDepositTransaction($id){
}
public function showAllDepositTransaction(){
}
}
Here is the database table that handles transactions. I can register a user and everything works perfectly, but when a customer makes a deposit, then I get the above error.
Schema::create('deposit_transactions', function (Blueprint $table) {
$table->bigIncrements('id');
$table->integer('customer_id');
$table->integer('agent_id');
$table->double('amount');
$table->string('sms_notification_status');
$table->timestamps();