added new blade component for payment_method ( #8669hjyqw )

This commit is contained in:
Cüneyt Şentürk 2023-03-22 16:52:21 +03:00
parent 831864f29a
commit 6b2cba6e61
6 changed files with 90 additions and 20 deletions

View File

@ -0,0 +1,81 @@
<?php
namespace App\View\Components;
use App\Abstracts\View\Component;
use App\Utilities\Modules;
use Illuminate\Support\Str;
class PaymentMethod extends Component
{
public $code, $method;
public $payment_methods;
public $payment_method;
public $type;
/**
* Create a new component instance.
*
* @return void
*/
public function __construct(
$code = null, $method = null, string $payment_method = null, array $payment_methods = [], $type = null
) {
$this->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;
}
}

View File

@ -0,0 +1,5 @@
@if (! empty($payment_method))
{!! $payment_method !!}
@else
<x-empty-data />
@endif

View File

@ -132,11 +132,7 @@
</td> </td>
<td valign="top" class="border-bottom-dashed-black" style="width:70%; margin: 0px; padding: 8px 0 0 0; font-size: 12px;"> <td valign="top" class="border-bottom-dashed-black" style="width:70%; margin: 0px; padding: 8px 0 0 0; font-size: 12px;">
@if (! empty($payment_methods[$transaction->payment_method])) <x-payment-method :method="$transaction->payment_method" />
{!! $payment_methods[$transaction->payment_method] !!}
@else
<x-empty-data />
@endif
</td> </td>
</tr> </tr>
@endif @endif

View File

@ -214,11 +214,7 @@
</td> </td>
<td valign="top" valign="top" class="border-bottom-dashed-black" style="width:70%; margin: 0px; padding: 8px 0 0 0; font-size: 12px;"> <td valign="top" valign="top" class="border-bottom-dashed-black" style="width:70%; margin: 0px; padding: 8px 0 0 0; font-size: 12px;">
@if (! empty($payment_methods[$transfer->expense_transaction->payment_method])) <x-payment-method :method="$transfer->expense_transaction->payment_method" />
{!! $payment_methods[$transfer->expense_transaction->payment_method] !!}
@else
<x-empty-data />
@endif
</td> </td>
</tr> </tr>
@stack('payment_method_input_end') @stack('payment_method_input_end')

View File

@ -30,11 +30,7 @@
</td> </td>
<td valign="top" style="width:70%; margin: 0px; padding: 8px 0 8px 0; font-size: 12px; border-bottom:1px solid #adadad;"> <td valign="top" style="width:70%; margin: 0px; padding: 8px 0 8px 0; font-size: 12px; border-bottom:1px solid #adadad;">
@if (! empty($payment_methods[$transfer->expense_transaction->payment_method])) <x-payment-method :method="$transfer->expense_transaction->payment_method" />
{!! $payment_methods[$transfer->expense_transaction->payment_method] !!}
@else
<x-empty-data />
@endif
</td> </td>
</tr> </tr>
@stack('payment_method_input_end') @stack('payment_method_input_end')

View File

@ -41,11 +41,7 @@
</x-table.td> </x-table.td>
<x-table.td class="w-4/12 sm:w-3/12"> <x-table.td class="w-4/12 sm:w-3/12">
@if (! empty($payment_methods[$item->payment_method])) <x-payment-method :method="$item->payment_method" type="customer" />
{!! $payment_methods[$item->payment_method] !!}
@else
<x-empty-data />
@endif
</x-table.td> </x-table.td>
<x-table.td class="w-3/12" hidden-mobile> <x-table.td class="w-3/12" hidden-mobile>