File "PaymentGatewayController.php"
Full path: /home/orbitecv/orbite-school.orbit.et/app/Http/Controllers/WebAdmin/PaymentGatewayController.php
File size: 2.04 KiB (2086 bytes)
MIME-type: text/x-php
Charset: utf-8
Download Open Edit Advanced Edit Back
<?php
namespace App\Http\Controllers\WebAdmin;
use App\Http\Controllers\Controller;
use App\Http\Requests\PaymentGatewayUpdateRequest;
use App\Models\PaymentGateway;
use Illuminate\Http\Request;
class PaymentGatewayController extends Controller
{
public function index()
{
$paypal = PaymentGateway::query()->where('name', 'paypal')->first();
$stripe = PaymentGateway::query()->where('name', 'stripe')->first();
$twoCheckout = PaymentGateway::query()->where('name', '2checkout')->first();
$aamarpay = PaymentGateway::query()->where('name', 'aamarpay')->first();
$razorpay = PaymentGateway::query()->where('name', 'razorpay')->first();
$bkash = PaymentGateway::query()->where('name', 'bkash')->first();
return view('payment_gateway.index', [
'paypal' => $paypal,
'stripe' => $stripe,
'twoCheckout' => $twoCheckout,
'aamarpay' => $aamarpay,
'razorpay' => $razorpay,
'bkash' => $bkash,
'paypalConfig' => json_decode($paypal->config),
'stripeConfig' => json_decode($stripe->config),
'twoCheckoutConfig' => json_decode($twoCheckout->config),
'aamarpayConfig' => json_decode($aamarpay->config),
'razorpayConfig' => json_decode($razorpay->config),
'bkashConfig' => json_decode($bkash->config),
]);
}
public function update(PaymentGateway $paymentGateway, PaymentGatewayUpdateRequest $request)
{
if (app()->isLocal()) {
return to_route('payment_gateway.index')->withError('Payment gateway cannot be updated in demo mode');
}
$isActive = false;
if (isset($request->is_active)) {
$isActive = $request->is_active == 'on' ? true : false;
}
$paymentGateway->update([
'config' => json_encode($request->except(['_token', '_method'])),
'is_active' => $isActive
]);
return to_route('payment_gateway.index')->withSuccess('Payment gateway updated');
}
}