|
@@ -6,9 +6,10 @@ use Livewire\Component;
|
|
|
|
|
|
|
|
class PaymentMethod extends Component
|
|
class PaymentMethod extends Component
|
|
|
{
|
|
{
|
|
|
- public $records, $name, $enabled, $money, $type, $corrispettivo_fiscale, $dataId, $bank_id, $update = false, $add = false;
|
|
|
|
|
|
|
+ public $records, $name, $enabled, $money, $type, $corrispettivo_fiscale, $dataId, $origin_id, $destination_id, $update = false, $add = false;
|
|
|
|
|
|
|
|
- public $banks = array();
|
|
|
|
|
|
|
+ public $origins = [];
|
|
|
|
|
+ public $destinations = [];
|
|
|
|
|
|
|
|
protected $rules = [
|
|
protected $rules = [
|
|
|
'name' => 'required'
|
|
'name' => 'required'
|
|
@@ -47,7 +48,8 @@ class PaymentMethod extends Component
|
|
|
if(\Auth::user()->level != env('LEVEL_ADMIN', 0))
|
|
if(\Auth::user()->level != env('LEVEL_ADMIN', 0))
|
|
|
return redirect()->to('/dashboard');
|
|
return redirect()->to('/dashboard');
|
|
|
|
|
|
|
|
- $this->banks = \App\Models\Bank::select('id', 'name')->get();
|
|
|
|
|
|
|
+ $this->origins = \App\Models\Bank::select('id', 'name')->where('enabled', true)->whereIn('visibility', ['OUT', 'ALL'])->get();
|
|
|
|
|
+ $this->destinations = \App\Models\Bank::select('id', 'name')->where('enabled', true)->whereIn('visibility', ['IN', 'ALL'])->get();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
public function render()
|
|
public function render()
|
|
@@ -55,7 +57,8 @@ class PaymentMethod extends Component
|
|
|
$this->records = \App\Models\PaymentMethod::all();
|
|
$this->records = \App\Models\PaymentMethod::all();
|
|
|
foreach($this->records as $r)
|
|
foreach($this->records as $r)
|
|
|
{
|
|
{
|
|
|
- $r->bank = $r->bank ? $r->bank->name : '';
|
|
|
|
|
|
|
+ $r->origin = $r->origin ? $r->origin->name : '';
|
|
|
|
|
+ $r->destination = $r->destination ? $r->destination->name : '';
|
|
|
}
|
|
}
|
|
|
/*if ($this->sortAsc)
|
|
/*if ($this->sortAsc)
|
|
|
$this->records = $this->records->sortBy($this->sortField);
|
|
$this->records = $this->records->sortBy($this->sortField);
|
|
@@ -77,7 +80,8 @@ class PaymentMethod extends Component
|
|
|
try {
|
|
try {
|
|
|
\App\Models\PaymentMethod::create([
|
|
\App\Models\PaymentMethod::create([
|
|
|
'name' => $this->name,
|
|
'name' => $this->name,
|
|
|
- 'bank_id' => $this->bank_id,
|
|
|
|
|
|
|
+ 'origin_id' => $this->origin_id != "" ? $this->origin_id : null,
|
|
|
|
|
+ 'destination_id' => $this->destination_id != "" ? $this->destination_id : null,
|
|
|
'money' => $this->money,
|
|
'money' => $this->money,
|
|
|
'type' => $this->type,
|
|
'type' => $this->type,
|
|
|
'corrispettivo_fiscale' => $this->corrispettivo_fiscale,
|
|
'corrispettivo_fiscale' => $this->corrispettivo_fiscale,
|
|
@@ -102,7 +106,8 @@ class PaymentMethod extends Component
|
|
|
$this->corrispettivo_fiscale = $payment_method->corrispettivo_fiscale;
|
|
$this->corrispettivo_fiscale = $payment_method->corrispettivo_fiscale;
|
|
|
$this->money = $payment_method->money;
|
|
$this->money = $payment_method->money;
|
|
|
$this->type = $payment_method->type;
|
|
$this->type = $payment_method->type;
|
|
|
- $this->bank_id = $payment_method->bank_id;
|
|
|
|
|
|
|
+ $this->origin_id = $payment_method->origin_id;
|
|
|
|
|
+ $this->destination_id = $payment_method->destination_id;
|
|
|
$this->dataId = $payment_method->id;
|
|
$this->dataId = $payment_method->id;
|
|
|
$this->update = true;
|
|
$this->update = true;
|
|
|
$this->add = false;
|
|
$this->add = false;
|
|
@@ -118,7 +123,8 @@ class PaymentMethod extends Component
|
|
|
try {
|
|
try {
|
|
|
\App\Models\PaymentMethod::whereId($this->dataId)->update([
|
|
\App\Models\PaymentMethod::whereId($this->dataId)->update([
|
|
|
'name' => $this->name,
|
|
'name' => $this->name,
|
|
|
- 'bank_id' => $this->bank_id,
|
|
|
|
|
|
|
+ 'origin_id' => $this->origin_id != "" ? $this->origin_id : null,
|
|
|
|
|
+ 'destination_id' => $this->destination_id != "" ? $this->destination_id : null,
|
|
|
'money' => $this->money,
|
|
'money' => $this->money,
|
|
|
'type' => $this->type,
|
|
'type' => $this->type,
|
|
|
'corrispettivo_fiscale' => $this->corrispettivo_fiscale,
|
|
'corrispettivo_fiscale' => $this->corrispettivo_fiscale,
|