Alessio_S10

GestioneTour.php

Jan 7th, 2025
35
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.19 KB | None | 0 0
  1. <?php
  2.  
  3. namespace App\Livewire;
  4.  
  5. use Carbon\Carbon;
  6. use Livewire\Component;
  7. use App\Models\MezzoData;
  8. use App\Models\MezzoTour;
  9.  
  10. class GestioneTour extends Component
  11. {
  12. public $mezzoTour;
  13. public $data;
  14. protected $listeners = ['day'];
  15.  
  16. public function day($data)
  17. {
  18. $this->data = $data; // Aggiorna la proprietà $data con la nuova data
  19. $this->mezzoTour = MezzoTour::with('mezzi', 'escursione', 'escursione.servizi')->where('data', $this->data)->get();
  20. }
  21. public function render()
  22. {
  23. $this->data = $this->data ?? Carbon::tomorrow()->format('Y-m-d');
  24. $MezzoTour = MezzoTour::with('mezzi','escursione','escursione.servizi')->where('data',$this->data)->get();
  25. foreach ($MezzoTour as $mt) {
  26. $mt->escursione->load('servizi');
  27. $mt->mezzoData=MezzoData::where('mezzo_id',$mt->mezzi->id)->where('data',$mt->data)->get();
  28. }
  29. $this->mezzoTour = $MezzoTour;
  30. return view('livewire.gestione-tour')->with(['mezzoTour' => $this->mezzoTour]);
  31. }
  32.  
  33. public function reinserisci() {
  34.  
  35. $this->mezzoTour="Reinserisci Tutti i Tour";
  36. return back();
  37. }
  38. }
  39.  
Advertisement
Add Comment
Please, Sign In to add comment