code = $code; $this->method = $method; $this->type = $type; $this->payment_methods = $this->getPaymentMethods($payment_methods, $type); $this->payment_method = $this->getPaymentMethod($payment_method, $code); } /** * Get the view / contents that represent the component. * * @return \Illuminate\Contracts\View\View|string */ public function render() { return view('components.payment_method'); } protected function getPaymentMethods($payment_methods, $type) { if (! empty($payment_methods)) { return $payment_methods; } // check here protal or admin panel.. if (empty($type)) { $type = Str::contains(request()->route()->getName(), 'portal') ? 'customer' : 'all'; } $payment_methods = Modules::getPaymentMethods($type); return $payment_methods; } protected function getPaymentMethod($payment_method, $code) { if (! empty($payment_methods)) { return $payment_methods; } if (! empty($this->payment_methods[$code])) { return $this->payment_methods[$code]; } if (! empty($this->payment_methods[$this->method])) { return $this->payment_methods[$this->method]; } if (! empty($this->payment_methods[$payment_method])) { return $this->payment_methods[$payment_method]; } return false; } }