2024-10-18 20:46:22 -05:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
use App\Models\Holding;
|
|
|
|
|
use Illuminate\Support\Collection;
|
|
|
|
|
use Livewire\Attributes\{Computed};
|
|
|
|
|
use Livewire\Volt\Component;
|
|
|
|
|
use Mary\Traits\Toast;
|
|
|
|
|
use Illuminate\Validation\Rule;
|
|
|
|
|
|
|
|
|
|
new class extends Component {
|
|
|
|
|
use Toast;
|
|
|
|
|
|
|
|
|
|
// props
|
|
|
|
|
public Holding $holding;
|
|
|
|
|
|
|
|
|
|
public Bool $reinvest_dividends = false;
|
|
|
|
|
|
|
|
|
|
// methods
|
|
|
|
|
public function rules()
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
return [
|
|
|
|
|
'reinvest_dividends' => ['required', 'boolean'],
|
|
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function mount()
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
$this->reinvest_dividends = $this->holding?->reinvest_dividends ?? false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function save()
|
|
|
|
|
{
|
|
|
|
|
$this->holding->update($this->validate());
|
|
|
|
|
|
2024-10-20 20:00:06 -05:00
|
|
|
$this->success(__('Holding options saved'));
|
2024-10-18 20:46:22 -05:00
|
|
|
|
2024-10-20 20:00:06 -05:00
|
|
|
$this->dispatch('toggle-holding-options');
|
2024-10-18 20:46:22 -05:00
|
|
|
}
|
|
|
|
|
}; ?>
|
|
|
|
|
|
2024-10-20 20:00:06 -05:00
|
|
|
<div class="" x-data="{ }"> {{-- grid lg:grid-cols-4 gap-10 --}}
|
|
|
|
|
<x-ib-form wire:submit="save" class=""> {{-- col-span-3 --}}
|
2024-10-18 20:46:22 -05:00
|
|
|
|
|
|
|
|
<x-toggle
|
2024-10-22 16:48:53 -05:00
|
|
|
label="{{ __('Reinvest Dividends') }}"
|
2024-10-18 20:46:22 -05:00
|
|
|
wire:model="reinvest_dividends"
|
|
|
|
|
right
|
|
|
|
|
hint="{{ __('Automatically generate buy transactions for any dividends earned.') }}"
|
|
|
|
|
/>
|
|
|
|
|
|
|
|
|
|
<x-slot:actions>
|
|
|
|
|
|
|
|
|
|
<x-button
|
|
|
|
|
label="{{ __('Save') }}"
|
|
|
|
|
type="submit"
|
|
|
|
|
icon="o-paper-airplane"
|
|
|
|
|
class="btn-primary"
|
|
|
|
|
spinner="save"
|
|
|
|
|
/>
|
|
|
|
|
</x-slot:actions>
|
|
|
|
|
</x-ib-form>
|
|
|
|
|
|
|
|
|
|
</div>
|