HasPasseggero.php 971 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. <?php
  2. namespace App\Http\Livewire\Traits;
  3. trait HasPasseggero{
  4. public function editPasseggero($x) {
  5. if (!in_array($x, [1, 2, 3, 4])) {
  6. return;
  7. }
  8. $this->currentPasseggero = $x;
  9. $propertyName = 'data_passeggero_' . ($x - 1);
  10. if (property_exists($this, $propertyName)) {
  11. $this->editAnagrafica($this->{$propertyName});
  12. $this->emit('load-anagrafica-modal');
  13. }
  14. }
  15. public function removePasseggero($x){
  16. if (!in_array($x, [1, 2, 3, 4])) {
  17. return;
  18. }
  19. $propertyName = 'data_passeggero_' . ($x - 1);
  20. if (property_exists($this, $propertyName)) {
  21. $this->{$propertyName} = 0;
  22. $this->emit('add-default-value', 0, '', $propertyName);
  23. }
  24. }
  25. public function addPasseggero($x){
  26. $this->resetAnagrafica();
  27. $this->currentPasseggero = $x;
  28. $this->emit('load-anagrafica-modal');
  29. }
  30. }