mirror of
https://github.com/pacnpal/thrillwiki_laravel.git
synced 2025-12-20 08:51:11 -05:00
Add models, enums, and services for user roles, theme preferences, slug history, and ID generation
This commit is contained in:
59
app/Livewire/AreaStatisticsComponent.php
Normal file
59
app/Livewire/AreaStatisticsComponent.php
Normal file
@@ -0,0 +1,59 @@
|
||||
<?php
|
||||
|
||||
namespace App\Livewire;
|
||||
|
||||
use App\Models\ParkArea;
|
||||
use Livewire\Component;
|
||||
|
||||
class AreaStatisticsComponent extends Component
|
||||
{
|
||||
public ParkArea $area;
|
||||
public bool $showDetails = false;
|
||||
public bool $showHistorical = false;
|
||||
|
||||
public function mount(ParkArea $area): void
|
||||
{
|
||||
$this->area = $area;
|
||||
}
|
||||
|
||||
public function toggleDetails(): void
|
||||
{
|
||||
$this->showDetails = !$this->showDetails;
|
||||
}
|
||||
|
||||
public function toggleHistorical(): void
|
||||
{
|
||||
$this->showHistorical = !$this->showHistorical;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the ride type distribution as percentages.
|
||||
*
|
||||
* @return array<string, float>
|
||||
*/
|
||||
protected function getRidePercentages(): array
|
||||
{
|
||||
if ($this->area->ride_count === 0) {
|
||||
return [
|
||||
'coasters' => 0,
|
||||
'flat_rides' => 0,
|
||||
'water_rides' => 0,
|
||||
];
|
||||
}
|
||||
|
||||
return [
|
||||
'coasters' => round(($this->area->coaster_count / $this->area->ride_count) * 100, 1),
|
||||
'flat_rides' => round(($this->area->flat_ride_count / $this->area->ride_count) * 100, 1),
|
||||
'water_rides' => round(($this->area->water_ride_count / $this->area->ride_count) * 100, 1),
|
||||
];
|
||||
}
|
||||
|
||||
public function render()
|
||||
{
|
||||
return view('livewire.area-statistics-component', [
|
||||
'rideDistribution' => $this->area->ride_distribution,
|
||||
'ridePercentages' => $this->getRidePercentages(),
|
||||
'historicalStats' => $this->area->historical_stats,
|
||||
]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user