Please verify if your $gateway
variable is initialized with the correct transaction object before using its properties.
xpdeal liked this reply
$gateway->charge is not object
check exist before use obj
like this
if (!empty($gateway->charge))
` public function manualPaymentAccept(Request $request) { $booking = Payment::where('transaction_id', $request->trx)->firstOrFail(); $general = GeneralSetting::first(); $gateway = Gateway::where('gateway_name', 'bank')->first();
$booking->payment_status = 1;
$booking->save();
refferMoney($booking->user_id, 'invest', $booking->amount);
Transaction::create([
'trx' => $booking->transaction_id,
'gateway_id' => $booking->gateway_id,
'amount' => $booking->amount,
'currency' => $general->site_currency,
'details' => 'Payment Successfull',
'charge' => $gateway->charge,
'type' => '-',
'user_id' => $booking->user_id,
'payment_status' => 1
]);`
I think there is no gateway created in the database with the name bank
that's why you are receiving the error message.
The solution to your problem is to check the $gateway
variable does not contain null
value before using it or the other simple way is to use firstOrFail
method instead of first
method as shown below:
$gateway = Gateway::where('gateway_name', 'bank')->firstOrFail();
This way you will get a 404
page intead of the error.
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community